[TASK] Cache non existing classes 79/25679/4
authorAlexander Stehlik <alexander.stehlik@googlemail.com>
Mon, 25 Nov 2013 23:07:40 +0000 (00:07 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Fri, 14 Feb 2014 15:34:08 +0000 (16:34 +0100)
To prevent multiple retries when loading information about non existing
classes (e.g. caused by class_exists() calls) the cache is filled with
an empty string when a non existing class is detected.

With this information the class loader can return early and does not
need to run all expensive checks for determining the class file.

Releases: 6.2
Resolves: #53962
Change-Id: I3c7e750bcce8846aaee79ac2d04527be2e31fc16
Reviewed-on: https://review.typo3.org/25679
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Core/ClassLoader.php

index 5cc2256..9005d77 100644 (file)
@@ -153,14 +153,19 @@ class ClassLoader {
                }
 
                $cacheEntryIdentifier = strtolower(str_replace('\\', '_', $className));
+               $classLoadingInformation = NULL;
                try {
                        $rawClassLoadingInformation = $this->classesCache->get($cacheEntryIdentifier);
                        if ($rawClassLoadingInformation !== FALSE) {
-                               $classLoadingInformation = explode("\xff", $rawClassLoadingInformation);
+                               if ($rawClassLoadingInformation !== '') {
+                                       $classLoadingInformation = explode("\xff", $rawClassLoadingInformation);
+                               }
                        } else {
                                $classLoadingInformation = $this->buildClassLoadingInformation($className);
                                if ($classLoadingInformation !== NULL) {
                                        $this->classesCache->set($cacheEntryIdentifier, implode("\xff", $classLoadingInformation), $this->isEarlyCache ? array('early') : array());
+                               } elseif (!$this->isEarlyCache) {
+                                       $this->classesCache->set($cacheEntryIdentifier, '');
                                }
                        }
                } catch (\InvalidArgumentException $exception) {