[BUGFIX] Ensure cache clearing is done properly by EM 72/28372/8
authorMarkus Klein <klein.t3@mfc-linz.at>
Thu, 13 Mar 2014 23:22:58 +0000 (00:22 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Sat, 15 Mar 2014 22:52:02 +0000 (23:52 +0100)
This fixes problems with access to classes from ext_localconf
files that were discarded from the classes cache at the wrong
time.

Resolves: #54906
Releases: 6.2
Change-Id: Icf650261a5ed72c36d332e3407ababf627968ab2
Reviewed-on: https://review.typo3.org/28372
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Thomas Maroschik
Tested-by: Thomas Maroschik
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
typo3/sysext/core/Classes/Cache/CacheManager.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Core/ClassLoader.php
typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php

index a045a25..ff4b18d 100644 (file)
@@ -40,7 +40,7 @@ class CacheManager implements \TYPO3\CMS\Core\SingletonInterface {
        protected $cacheFactory;
 
        /**
-        * @var array
+        * @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface[]
         */
        protected $caches = array();
 
index ef5a68b..2e294d8 100644 (file)
@@ -272,7 +272,7 @@ class Bootstrap {
         * Beware! This is not public API and necessary for edge cases in the install tool
         *
         * @param string $packageManagerClassName
-        * @return void
+        * @return Bootstrap
         */
        public function reinitializeClassLoaderAndCachesAndPackageManagement($packageManagerClassName = 'TYPO3\\CMS\\Core\\Package\\PackageManager') {
                $currentClassLoader = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Core\\ClassLoader');
@@ -284,6 +284,7 @@ class Bootstrap {
                        ->initializeCachingFramework()
                        ->initializeClassLoaderCaches()
                        ->initializePackageManagement($packageManagerClassName);
+               return $this;
        }
 
        /**
@@ -351,22 +352,6 @@ class Bootstrap {
        }
 
        /**
-        * Load TYPO3_LOADED_EXT, recreate class loader registry and load ext_localconf
-        *
-        * @TODO: This method was changed with the package manager patch, do we still need it?
-        * @return Bootstrap
-        * @internal This is not a public API method, do not use in own extensions
-        */
-       public function reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf() {
-               $bootstrap = $this->getInstance();
-               // Commented out for package management patch, method is still used in extensionmanager
-               //              $bootstrap->populateTypo3LoadedExtGlobal(FALSE);
-               //              ClassLoader::loadClassLoaderCache();
-               $bootstrap->loadAdditionalConfigurationFromExtensions(FALSE);
-               return $this;
-       }
-
-       /**
         * Sets up additional configuration applied in all scopes
         *
         * @return Bootstrap
index 3c37dde..3401ade 100644 (file)
@@ -153,6 +153,7 @@ class ClassLoader {
 
                $cacheEntryIdentifier = strtolower(str_replace('\\', '_', $className));
                $classLoadingInformation = $this->getClassLoadingInformationFromCache($cacheEntryIdentifier);
+
                if ($classLoadingInformation === NULL) {
                        $classLoadingInformation = $this->buildCachedClassLoadingInformation($cacheEntryIdentifier, $className);
                }
@@ -410,6 +411,7 @@ class ClassLoader {
         */
        public function setPackages(array $packages) {
                $this->packages = $packages;
+
                if (!$this->loadPackageNamespacesFromCache()) {
                        $this->buildPackageNamespacesAndClassesPaths();
                } else {
index 12283fa..ba911a7 100644 (file)
@@ -131,6 +131,8 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
                $this->saveDefaultConfiguration($extension['key']);
                if ($extension['clearcacheonload']) {
                        $this->cacheManager->flushCaches();
+               } else {
+                       $this->cacheManager->flushCachesInGroup('system');
                }
        }
 
@@ -185,7 +187,7 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
         */
        protected function unloadExtension($extensionKey) {
                $this->packageManager->deactivatePackage($extensionKey);
-               $this->reloadCaches();
+               $this->cacheManager->flushCachesInGroup('system');
        }
 
        /**
@@ -297,8 +299,8 @@ class InstallUtility implements \TYPO3\CMS\Core\SingletonInterface {
         * @return void
         */
        public function reloadCaches() {
-               $this->cacheManager->flushCachesInGroup('system');
-               \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf()->loadExtensionTables();
+               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtLocalconf(FALSE);
+               \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadExtensionTables(FALSE);
        }
 
        /**
index 71304ea..cb466f7 100644 (file)
@@ -126,6 +126,9 @@ class InstallUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        ->method('processRuntimeDatabaseUpdates')
                        ->with($this->extensionKey);
 
+               $cacheManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager');
+               $cacheManagerMock->expects($this->once())->method('flushCachesInGroup');
+               $this->installMock->_set('cacheManager', $cacheManagerMock);
                $this->installMock->install($this->extensionKey);
        }
 
@@ -133,6 +136,9 @@ class InstallUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function installCallsLoadExtension() {
+               $cacheManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager');
+               $cacheManagerMock->expects($this->once())->method('flushCachesInGroup');
+               $this->installMock->_set('cacheManager', $cacheManagerMock);
                $this->installMock->expects($this->once())->method('loadExtension');
                $this->installMock->install($this->extensionKey);
        }
@@ -152,6 +158,9 @@ class InstallUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function installationOfAnExtensionWillCallEnsureThatDirectoriesExist() {
+               $cacheManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager');
+               $cacheManagerMock->expects($this->once())->method('flushCachesInGroup');
+               $this->installMock->_set('cacheManager', $cacheManagerMock);
                $this->installMock->expects($this->once())->method('ensureConfiguredDirectoriesExist');
                $this->installMock->install($this->extensionKey);
        }
@@ -160,6 +169,9 @@ class InstallUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function installCallsReloadCaches() {
+               $cacheManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager');
+               $cacheManagerMock->expects($this->once())->method('flushCachesInGroup');
+               $this->installMock->_set('cacheManager', $cacheManagerMock);
                $this->installMock->expects($this->once())->method('reloadCaches');
                $this->installMock->install('dummy');
        }
@@ -168,6 +180,9 @@ class InstallUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function installCallsSaveDefaultConfigurationWithExtensionKey() {
+               $cacheManagerMock = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager');
+               $cacheManagerMock->expects($this->once())->method('flushCachesInGroup');
+               $this->installMock->_set('cacheManager', $cacheManagerMock);
                $this->installMock->expects($this->once())->method('saveDefaultConfiguration')->with('dummy');
                $this->installMock->install('dummy');
        }