[BUGFIX] Inefficient cache handling in LocalizationFactory 21/19921/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 13 Apr 2013 12:13:56 +0000 (14:13 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 13 Apr 2013 13:37:54 +0000 (15:37 +0200)
Calling has() in front of get() is inefficient and can be optimized.

Change-Id: Id8048023cc2305534a494664b402d47911087db6
Fixes: #47184
Releases: 6.1, 6.0
Reviewed-on: https://review.typo3.org/19921
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Localization/LocalizationFactory.php

index 865d849..702bf98 100644 (file)
@@ -96,12 +96,14 @@ class LocalizationFactory implements \TYPO3\CMS\Core\SingletonInterface {
                        if ($this->store->hasData($fileReference, $languageKey)) {
                                return $this->store->getData($fileReference);
                        }
+
                        // If the content is in cache (system cache), use it
-                       if ($this->cacheInstance->has($hash)) {
-                               // Load data from the caching framework
-                               $this->store->setData($fileReference, $languageKey, $this->cacheInstance->get($hash));
+                       $data = $this->cacheInstance->get($hash);
+                       if ($data !== FALSE) {
+                               $this->store->setData($fileReference, $languageKey, $data);
                                return $this->store->getData($fileReference, $languageKey);
                        }
+
                        $this->store->setConfiguration($fileReference, $languageKey, $charset);
                        /** @var $parser \TYPO3\CMS\Core\Localization\Parser\LocalizationParserInterface */
                        $parser = $this->store->getParserInstance($fileReference);