[BUGFIX] Sprite manager cache improvement 79/23479/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 29 Aug 2013 19:40:15 +0000 (21:40 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 29 Aug 2013 20:04:30 +0000 (22:04 +0200)
The sprite manager cache entry is created and then required
directly again. This may lead to runtime issues if the file
is required already before it is fully written.
The patch optimizes that by setting the runtime information
directly from the given data.

Change-Id: I3f6250d8513dad32e266538a075abc8e3daeb68c
Resolves: #51544
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/23479
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/backend/Classes/Sprite/SpriteManager.php

index 906cb20..591211d 100644 (file)
@@ -63,8 +63,7 @@ class SpriteManager {
                        if ($codeCache->has($cacheIdentifier)) {
                                $codeCache->requireOnce($cacheIdentifier);
                        } else {
-                               static::createSpriteCache();
-                               $codeCache->requireOnce($cacheIdentifier);
+                               static::buildSpriteDataAndCreateCacheEntry();
                        }
                        self::$isInitialized = TRUE;
                }
@@ -80,15 +79,15 @@ class SpriteManager {
        }
 
        /**
-        * Compile sprite icon cache by calling the registered generator.
+        * Set up sprite icon data and create cache entry calling the registered generator.
         *
         * Stuff the compiled $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable']
-        * global into php code cache
+        * global into php code cache.
         *
         * @throws \RuntimeException
         * @return void
         */
-       static protected function createSpriteCache() {
+       static protected function buildSpriteDataAndCreateCacheEntry() {
                $handlerClass = $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'];
                /** @var $handler \TYPO3\CMS\Backend\Sprite\SpriteIconGeneratorInterface */
                $handler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($handlerClass);
@@ -110,6 +109,7 @@ class SpriteManager {
                // Merge icon names provided by the skin, with
                // registered "complete sprites" and the handler class
                $iconNames = array_merge($availableSkinIcons, (array) $GLOBALS['TBE_STYLES']['spritemanager']['spriteIconsAvailable'], $handler->getAvailableIconNames());
+               $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'] = $iconNames;
                $cacheString = addslashes(serialize($iconNames));
                $cacheFileContent = '$GLOBALS[\'TBE_STYLES\'][\'spriteIconApi\'][\'iconsAvailable\'] = unserialize(stripslashes(\'' . $cacheString . '\'));';
                /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
@@ -180,4 +180,4 @@ class SpriteManager {
 }
 
 
-?>
\ No newline at end of file
+?>