From 276ff8fb3bc88aae9751cba784499a323023159e Mon Sep 17 00:00:00 2001 From: Ingo Renner Date: Mon, 20 Oct 2008 10:40:18 +0000 Subject: [PATCH] minor cleanup of singleton handling git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4333 709f56b5-9817-0410-a4d7-c38de5d9e867 --- t3lib/class.t3lib_div.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/t3lib/class.t3lib_div.php b/t3lib/class.t3lib_div.php index 1093581f26eb..7d9ab7f90dcf 100755 --- a/t3lib/class.t3lib_div.php +++ b/t3lib/class.t3lib_div.php @@ -4584,7 +4584,7 @@ final class t3lib_div { // Load class file if not found: if (!class_exists($className)) { - if (substr($className,0,6)=='t3lib_') { + if (substr($className,0,6) == 't3lib_') { t3lib_div::requireOnce(PATH_t3lib.'class.'.strtolower($className).'.php'); } } @@ -4593,14 +4593,17 @@ final class t3lib_div { $className = t3lib_div::makeInstanceClassName($className); if (isset($instances[$className])) { - return $instances[$className]; - } - $instance = new $className; - if ($instance instanceof t3lib_Singleton) { - $instances[$className] = $instance; + // it's a singleton, get the existing instance + $instance = $instances[$className]; + } else { + $instance = new $className; + + if ($instance instanceof t3lib_Singleton) { + // it's a singleton, save the instance for later reuse + $instances[$className] = $instance; + } } - // Return object. return $instance; } -- 2.20.1