[+BUGFIX] Extbase (Caching): Using reworked caching framework now. Patch by Olly...
authorSebastian Kurfürst <sebastian@typo3.org>
Fri, 18 Sep 2009 13:10:15 +0000 (13:10 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Fri, 18 Sep 2009 13:10:15 +0000 (13:10 +0000)
typo3/sysext/extbase/Classes/Dispatcher.php
typo3/sysext/extbase/Classes/Utility/Cache.php
typo3/sysext/extbase/ext_tables.php

index d9d1dd2..ee9d2cc 100644 (file)
@@ -72,6 +72,7 @@ class Tx_Extbase_Dispatcher {
         * Constructs this Dispatcher and registers the autoloader
         */
        public function __construct() {
+               t3lib_cache::initializeCachingFramework();
                $this->initializeClassLoader();
        }
 
@@ -184,7 +185,9 @@ class Tx_Extbase_Dispatcher {
                $flashMessages->reset();
                $controller->injectFlashMessages($flashMessages);
 
-               $cacheManager = t3lib_div::makeInstance('t3lib_cache_Manager');
+               /** @var $cacheManager t3lib_cache_Manager */
+               $cacheManager = $GLOBALS['typo3CacheManager'];
+
                try {
                        self::$reflectionService->setCache($cacheManager->getCache('cache_extbase_reflection'));
                } catch (t3lib_cache_exception_NoSuchCache $exception) {
index d8a1a86..d0ed0a3 100644 (file)
@@ -40,12 +40,55 @@ class Tx_Extbase_Utility_Cache {
         * @return void
         */
        static public function clearPageCache(array $pageIdsToClear) {
-               $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
-               $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
+               self::flushPageCache($pageIdsToClear);
+               self::flushPageSectionCache($pageIdsToClear);
+       }
+
+       /**
+        * Flushes cache_pages or cachinframework_cache_pages.
+        *
+        * @param       array           $pageIds: (optional) Ids of pages to be deleted
+        * @return      void
+        */
+       static protected function flushPageCache(array $pageIds = NULL) {
+               if (TYPO3_UseCachingFramework) {
+                       $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
+
+                       if (!is_null($pageIds)) {
+                               foreach ($pageIds as $pageId) {
+                                       $pageCache->flushByTag('pageId_' . $pageId);
+                               }
+                       } else {
+                               $pageCache->flush();
+                       }
+               } elseif (!is_null($pageIds)) {
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN (' . implode(',', $pageIds) . ')');
+               } else {
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', '');
+               }
+       }
+
+       /**
+        * Flushes cache_pagesection or cachingframework_cache_pagesection.
+        *
+        * @param       array   $pageIds: (optional) Ids of pages to be deleted
+        * @return      void
+        */
+       static protected function flushPageSectionCache(array $pageIds = NULL) {
+               if (TYPO3_UseCachingFramework) {
+                       $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
 
-               foreach ($pageIdsToClear as $pageIdToClear) {
-                       $pageCache->flushByTag('pageId_' . $pageIdToClear);
-                       $pageSectionCache->flushByTag('pageId_' . $pageIdToClear);
+                       if (!is_null($pageIds)) {
+                               foreach ($pageIds as $pageId) {
+                                       $pageSectionCache->flushByTag('pageId_' . $pageId);
+                               }
+                       } else {
+                               $pageSectionCache->flush();
+                       }
+               } elseif (!is_null($pageIds)) {
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', 'page_id IN (' . implode(',',$pageIds) . ')');
+               } else {
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', '');
                }
        }
 }
index e261d64..50da33f 100644 (file)
@@ -5,6 +5,7 @@ if (!defined ('TYPO3_MODE')) die ('Access denied.');
 if (TYPO3_MODE == 'BE') {
        // register the cache in BE so it will be cleared with "clear all caches"
        try {
+               t3lib_cache::initializeCachingFramework();
                $GLOBALS['typo3CacheFactory']->create(
                        'tx_extbase_cache_reflection',
                        't3lib_cache_frontend_VariableFrontend',