Commit 03db4eaa authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] Remove access to constant TYPO3_UseCachingFramework

The caching framework is always enabled and access
to this constant is deprecated.

Change-Id: Ibb46f5ab1908cb26bc91d42d15e1e12a95156174
Resolves: #36039
Related: #36037
Releases: 6.0
parent bcea74aa
......@@ -30,12 +30,6 @@
*/
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
*
......@@ -58,23 +52,14 @@ class Tx_Extbase_Service_CacheService implements t3lib_Singleton {
* @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 {
$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) {
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 {
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_pagesection');
$pageSectionCache->flush();
}
}
}
......
......@@ -95,7 +95,7 @@ class Tx_Extbase_Tests_Unit_Service_CacheServiceTest extends Tx_Extbase_Tests_Un
/**
* @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');
......@@ -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));
$this->cacheService->_set('useCachingFramework', TRUE);
$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));
$this->cacheService->_set('useCachingFramework', TRUE);
$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');
......@@ -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));
$this->cacheService->_set('useCachingFramework', TRUE);
$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));
$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');
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment