[BUGFIX] Cache missing class information only in productive context 85/32685/3
authorNicole Cordes <typo3@cordes.co>
Tue, 9 Sep 2014 13:18:27 +0000 (15:18 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 9 Sep 2014 13:21:55 +0000 (15:21 +0200)
To improve cache handling during development, missing class information
shouldn't be cached anymore. Otherwise each time a class was misspelled
and not found we have to clear the classes_cache.

Resolves: #61475
Releases: 6.3, 6.2
Change-Id: I7de24348e84bd89afd81164b90f776a996fcb8d9
Reviewed-on: http://review.typo3.org/32685
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Core/ClassLoader.php

index f2b7226..4d9b4cc 100644 (file)
@@ -28,6 +28,11 @@ class ClassLoader {
        const VALID_CLASSNAME_PATTERN = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9\\\\_\x7f-\xff]*$/';
 
        /**
+        * @var ApplicationContext
+        */
+       protected $context;
+
+       /**
         * @var ClassAliasMap
         */
        protected $classAliasMap;
@@ -93,6 +98,7 @@ class ClassLoader {
         * @param ApplicationContext $context
         */
        public function __construct(ApplicationContext $context) {
+               $this->context = $context;
                $this->classesCache = new Cache\Frontend\StringFrontend('cache_classes', new Cache\Backend\TransientMemoryBackend($context));
        }
 
@@ -241,8 +247,10 @@ class ClassLoader {
                                        $this->isEarlyCache ? array('early') : array()
                                );
                        } elseif (!$this->isEarlyCache) {
-                               // Cache that the class is unknown
-                               $this->classesCache->set($cacheEntryIdentifier, '');
+                               if ($this->context->isProduction()) {
+                                       // Cache that the class is unknown
+                                       $this->classesCache->set($cacheEntryIdentifier, '');
+                               }
                        }
                }