[TASK] Remove access to constant TYPO3_UseCachingFramework
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 14 Apr 2012 13:20:03 +0000 (15:20 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 14 Apr 2012 13:21:07 +0000 (15:21 +0200)
The caching framework is always enabled and access
to this constant is deprecated.

Change-Id: Ibb46f5ab1908cb26bc91d42d15e1e12a95156174
Resolves: #36039
Related: #36037
Releases: 6.0

typo3/sysext/extbase/Classes/Service/CacheService.php
typo3/sysext/extbase/Tests/Unit/Service/CacheServiceTest.php

index 63e39bc..8de4ed6 100644 (file)
  */
 class Tx_Extbase_Service_CacheService implements t3lib_Singleton {
 
  */
 class Tx_Extbase_Service_CacheService implements t3lib_Singleton {
 
-       /**
-        * This is a wrapper for the global constant "TYPO3_UseCachingFramework" to make this class testable
-        * @var boolean
-        */
-       protected $useCachingFramework = TYPO3_UseCachingFramework;
-
        /**
         * Clears the page cache
         *
        /**
         * Clears the page cache
         *
@@ -58,23 +52,14 @@ class Tx_Extbase_Service_CacheService implements t3lib_Singleton {
         * @return void
         */
        protected function flushPageCache($pageIds = NULL) {
         * @return void
         */
        protected function flushPageCache($pageIds = NULL) {
-               if ($this->useCachingFramework) {
-                       $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
+               $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
 
 
-                       if ($pageIds !== NULL) {
-                               foreach ($pageIds as $pageId) {
-                                       $pageCache->flushByTag('pageId_' . $pageId);
-                               }
-                       } else {
-                               $pageCache->flush();
+               if ($pageIds !== NULL) {
+                       foreach ($pageIds as $pageId) {
+                               $pageCache->flushByTag('pageId_' . $pageId);
                        }
                        }
-               } elseif ($pageIds !== NULL) {
-                       $GLOBALS['TYPO3_DB']->exec_DELETEquery(
-                               'cache_pages',
-                               'page_id IN (' . implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($pageIds)) . ')'
-                       );
                } else {
                } else {
-                       $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_pages');
+                       $pageCache->flush();
                }
        }
 
                }
        }
 
@@ -85,23 +70,14 @@ class Tx_Extbase_Service_CacheService implements t3lib_Singleton {
         * @return void
         */
        protected function flushPageSectionCache($pageIds = NULL) {
         * @return void
         */
        protected function flushPageSectionCache($pageIds = NULL) {
-               if ($this->useCachingFramework) {
-                       $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
+               $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
 
 
-                       if ($pageIds !== NULL) {
-                               foreach ($pageIds as $pageId) {
-                                       $pageSectionCache->flushByTag('pageId_' . $pageId);
-                               }
-                       } else {
-                               $pageSectionCache->flush();
+               if ($pageIds !== NULL) {
+                       foreach ($pageIds as $pageId) {
+                               $pageSectionCache->flushByTag('pageId_' . $pageId);
                        }
                        }
-               } elseif ($pageIds !== NULL) {
-                       $GLOBALS['TYPO3_DB']->exec_DELETEquery(
-                               'cache_pagesection',
-                               'page_id IN (' . implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($pageIds)) . ')'
-                       );
                } else {
                } else {
-                       $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_pagesection');
+                       $pageSectionCache->flush();
                }
        }
 }
                }
        }
 }
index 598c414..ff50150 100644 (file)
@@ -95,7 +95,7 @@ class Tx_Extbase_Tests_Unit_Service_CacheServiceTest extends Tx_Extbase_Tests_Un
        /**
         * @test
         */
        /**
         * @test
         */
-       public function flushPageCacheUsesCacheManagerToFlushCacheOfSpecifiedPagesIfCachingFrameworkIsEnabled() {
+       public function flushPageCacheUsesCacheManagerToFlushCacheOfSpecifiedPages() {
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->at(0))->method('flushByTag')->with('pageId_1');
                $mockCacheFrontend->expects($this->at(1))->method('flushByTag')->with('pageId_2');
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->at(0))->method('flushByTag')->with('pageId_1');
                $mockCacheFrontend->expects($this->at(1))->method('flushByTag')->with('pageId_2');
@@ -103,51 +103,25 @@ class Tx_Extbase_Tests_Unit_Service_CacheServiceTest extends Tx_Extbase_Tests_Un
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pages')->will($this->returnValue($mockCacheFrontend));
 
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pages')->will($this->returnValue($mockCacheFrontend));
 
-               $this->cacheService->_set('useCachingFramework', TRUE);
                $this->cacheService->_call('flushPageCache', array(1,2,3));
        }
 
        /**
         * @test
         */
                $this->cacheService->_call('flushPageCache', array(1,2,3));
        }
 
        /**
         * @test
         */
-       public function flushPageCacheUsesCacheManagerToFlushCacheOfAllPagesIfCachingFrameworkIsEnabledAndPageIdsIsNull() {
+       public function flushPageCacheUsesCacheManagerToFlushCacheOfAllPagesIfPageIdsIsNull() {
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->once())->method('flush');
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pages')->will($this->returnValue($mockCacheFrontend));
 
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->once())->method('flush');
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pages')->will($this->returnValue($mockCacheFrontend));
 
-               $this->cacheService->_set('useCachingFramework', TRUE);
                $this->cacheService->_call('flushPageCache');
        }
 
        /**
         * @test
         */
                $this->cacheService->_call('flushPageCache');
        }
 
        /**
         * @test
         */
-       public function flushPageCacheFlushesCacheOfSpecifiedPagesDirectlyIfCachingFrameworkIsDisabled() {
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('cleanIntArray')->with(array(1,2,3))->will($this->returnValue(array(3,2,1)));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_DELETEquery')->with(
-                       'cache_pages',
-                       'page_id IN (3,2,1)'
-               );
-
-               $this->cacheService->_set('useCachingFramework', FALSE);
-               $this->cacheService->_call('flushPageCache', array(1,2,3));
-       }
-
-       /**
-        * test
-        */
-       public function flushPageCacheFlushesCacheOfAllPagesDirectlyIfCachingFrameworkIsDisabled() {
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_TRUNCATEquery')->with('cache_pages');
-
-               $this->cacheService->_set('useCachingFramework', FALSE);
-               $this->cacheService->_call('flushPageCache');
-       }
-
-       /**
-        * @test
-        */
-       public function flushPageSectionCacheUsesCacheManagerToFlushCacheOfSpecifiedPageSectionsIfCachingFrameworkIsEnabled() {
+       public function flushPageSectionCacheUsesCacheManagerToFlushCacheOfSpecifiedPageSections() {
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->at(0))->method('flushByTag')->with('pageId_1');
                $mockCacheFrontend->expects($this->at(1))->method('flushByTag')->with('pageId_2');
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->at(0))->method('flushByTag')->with('pageId_1');
                $mockCacheFrontend->expects($this->at(1))->method('flushByTag')->with('pageId_2');
@@ -155,44 +129,18 @@ class Tx_Extbase_Tests_Unit_Service_CacheServiceTest extends Tx_Extbase_Tests_Un
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pagesection')->will($this->returnValue($mockCacheFrontend));
 
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pagesection')->will($this->returnValue($mockCacheFrontend));
 
-               $this->cacheService->_set('useCachingFramework', TRUE);
                $this->cacheService->_call('flushPageSectionCache', array(1,2,3));
        }
 
        /**
         * @test
         */
                $this->cacheService->_call('flushPageSectionCache', array(1,2,3));
        }
 
        /**
         * @test
         */
-       public function flushPageSectionCacheUsesCacheManagerToFlushCacheOfAllPageSectionsIfCachingFrameworkIsEnabledAndPageIdsIsNull() {
+       public function flushPageSectionCacheUsesCacheManagerToFlushCacheOfAllPageSectionsIfPageIdsIsNull() {
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->once())->method('flush');
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pagesection')->will($this->returnValue($mockCacheFrontend));
 
                $mockCacheFrontend = $this->getMock('t3lib_cache_frontend_Frontend');
                $mockCacheFrontend->expects($this->once())->method('flush');
 
                $GLOBALS['typo3CacheManager']->expects($this->once())->method('getCache')->with('cache_pagesection')->will($this->returnValue($mockCacheFrontend));
 
-               $this->cacheService->_set('useCachingFramework', TRUE);
-               $this->cacheService->_call('flushPageSectionCache');
-       }
-
-       /**
-        * @test
-        */
-       public function flushPageSectionCacheFlushesCacheOfSpecifiedPageSectionsDirectlyIfCachingFrameworkIsDisabled() {
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('cleanIntArray')->with(array(1,2,3))->will($this->returnValue(array(3,2,1)));
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_DELETEquery')->with(
-                       'cache_pagesection',
-                       'page_id IN (3,2,1)'
-               );
-
-               $this->cacheService->_set('useCachingFramework', FALSE);
-               $this->cacheService->_call('flushPageSectionCache', array(1,2,3));
-       }
-
-       /**
-        * test
-        */
-       public function flushPageSectionCacheCacheFlushesCacheOfAllPageSectionsDirectlyIfCachingFrameworkIsDisabled() {
-               $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_TRUNCATEquery')->with('cache_pagesection');
-
-               $this->cacheService->_set('useCachingFramework', FALSE);
                $this->cacheService->_call('flushPageSectionCache');
        }
 
                $this->cacheService->_call('flushPageSectionCache');
        }