/**
  * @test
  */
 public function removeCacheFilesFlushesSystemCaches()
 {
     /** @var CacheManager|\PHPUnit_Framework_MockObject_MockObject $mockCacheManager */
     $mockCacheManager = $this->getMock(CacheManager::class, array('flushCachesInGroup'));
     $mockCacheManager->expects($this->once())->method('flushCachesInGroup')->with('system');
     ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
     ExtensionManagementUtility::removeCacheFiles();
 }
예제 #2
0
 public function setUp()
 {
     $this->testingFramework = new Tx_Phpunit_Framework('additional_reports');
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
 }
예제 #3
0
 /**
  * Generates update wizard
  *
  * @return void
  * @todo Define visibility
  */
 public function updateWizard()
 {
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
     // Forces creation / update of caching framework tables that are needed by some update wizards
     $cacheTablesConfiguration = implode(LF, $this->sqlHandler->getStatementArray(\TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions(), 1, '^CREATE TABLE '));
     $neededTableDefinition = $this->sqlHandler->getFieldDefinitions_fileContent($cacheTablesConfiguration);
     $currentTableDefinition = $this->sqlHandler->getFieldDefinitions_database();
     $updateTableDefenition = $this->sqlHandler->getDatabaseExtra($neededTableDefinition, $currentTableDefinition);
     $updateStatements = $this->sqlHandler->getUpdateSuggestions($updateTableDefenition);
     if (isset($updateStatements['create_table']) && count($updateStatements['create_table']) > 0) {
         $this->sqlHandler->performUpdateQueries($updateStatements['create_table'], $updateStatements['create_table']);
     }
     if (isset($updateStatements['add']) && count($updateStatements['add']) > 0) {
         $this->sqlHandler->performUpdateQueries($updateStatements['add'], $updateStatements['add']);
     }
     if (isset($updateStatements['change']) && count($updateStatements['change']) > 0) {
         $this->sqlHandler->performUpdateQueries($updateStatements['change'], $updateStatements['change']);
     }
     // call wizard
     $action = $this->INSTALL['database_type'] ? $this->INSTALL['database_type'] : 'checkForUpdate';
     $this->updateWizard_parts($action);
     $this->output($this->outputWrapper($this->printAll()));
 }
 /**
  * @test
  */
 public function removeCacheFilesFlushesSystemCaches()
 {
     $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('flushCachesInGroup'));
     $mockCacheManager->expects($this->once())->method('flushCachesInGroup')->with('system');
     ExtensionManagementUtilityAccessibleProxy::setCacheManager($mockCacheManager);
     ExtensionManagementUtility::removeCacheFiles();
 }
 /**
  * Writes the extension's configuration (version for TYPO3 CMS 6.0+)
  *
  * @param $extensionConfiguration
  * @return void
  */
 protected function writeExtensionConfiguration($extensionConfiguration)
 {
     /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
     $configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
     $configurationManager->setLocalConfigurationValueByPath('EXT/extConf/caretaker_instance', serialize($extensionConfiguration));
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
 }
예제 #6
0
 /**
  * @param array $localconfValues
  * @return void
  */
 private function writeLocalconfArray(array $localconfValues)
 {
     if (!$this->configurationManager instanceof ConfigurationManager) {
         $this->configurationManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
     }
     $this->configurationManager->setLocalConfigurationValueByPath('EXT/extConf/snowbabel', serialize($localconfValues));
     ExtensionManagementUtility::removeCacheFiles();
 }
 /**
  * @test
  */
 public function removeCacheFilesFlushesCache()
 {
     $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'), array(), '', FALSE);
     $GLOBALS['typo3CacheManager'] = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache'));
     $GLOBALS['typo3CacheManager']->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
     $mockCache->expects($this->once())->method('flush');
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
 }
예제 #8
0
 /**
  * Writes the TSstyleconf values to "localconf.php"
  * Removes the temp_CACHED* files before return.
  *
  * @param string $extensionKey Extension key
  * @param array $newConfiguration Configuration array to write back
  * @return void
  */
 public function writeExtensionTypoScriptStyleConfigurationToLocalconf($extensionKey, $newConfiguration)
 {
     $this->configurationManager->setLocalConfigurationValueByPath('EXT/extConf/' . $extensionKey, serialize($newConfiguration));
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
 }
예제 #9
0
 /**
  * Clears the cache based on the command $cacheCmd.
  *
  * $cacheCmd='pages':	Clears cache for all pages. Requires admin-flag to
  * be set for BE_USER.
  *
  * $cacheCmd='all':		Clears all cache_tables. This is necessary if
  * templates are updated. Requires admin-flag to be set for BE_USER.
  *
  * $cacheCmd=[integer]:	Clears cache for the page pointed to by $cacheCmd
  * (an integer).
  *
  * $cacheCmd='cacheTag:[string]':  Flush page and pagesection cache by given tag
  *
  * $cacheCmd='cacheId:[string]':  Removes cache identifier from page and page section cache
  *
  * Can call a list of post processing functions as defined in
  * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']
  * (numeric array with values being the function references, called by
  * t3lib_div::callUserFunction()).
  *
  * Note: The following cache_* are intentionally not cleared by
  * $cacheCmd='all':
  *
  * - cache_md5params:	RDCT redirects.
  * - cache_imagesizes:	Clearing this table would cause a lot of unneeded
  * Imagemagick calls because the size informations have
  * to be fetched again after clearing.
  *
  * @param string $cacheCmd The cache command, see above description
  * @return void
  */
 public function clear_cacheCmd($cacheCmd)
 {
     if (is_object($this->BE_USER)) {
         $this->BE_USER->writelog(3, 1, 0, 0, 'User %s has cleared the cache (cacheCmd=%s)', array($this->BE_USER->user['username'], $cacheCmd));
     }
     // Clear cache for either ALL pages or ALL tables!
     switch (strtolower($cacheCmd)) {
         case 'pages':
             if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) {
                 $this->internal_clearPageCache();
             }
             break;
         case 'all':
             if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
                 // Clear all caching framework caches
                 $GLOBALS['typo3CacheManager']->flushCaches();
                 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
                     $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_treelist');
                 }
                 // Clearing additional cache tables:
                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearAllCache_additionalTables'])) {
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearAllCache_additionalTables'] as $tableName) {
                         if (!preg_match('/[^[:alnum:]_]/', $tableName) && substr($tableName, -5) === 'cache') {
                             $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery($tableName);
                         } else {
                             throw new \RuntimeException('TYPO3 Fatal Error: Trying to flush table "' . $tableName . '" with "Clear All Cache"', 1270853922);
                         }
                     }
                 }
             }
             \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
             break;
         case 'temp_cached':
             \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
             break;
     }
     $tagsToFlush = array();
     // Clear cache for a page ID!
     if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($cacheCmd)) {
         if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
             $list_cache = array($cacheCmd);
             // Call pre-processing function for clearing of cache for page ids:
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearPageCacheEval'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearPageCacheEval'] as $funcName) {
                     $_params = array('pageIdArray' => &$list_cache, 'cacheCmd' => $cacheCmd, 'functionID' => 'clear_cacheCmd()');
                     // Returns the array of ids to clear, FALSE if nothing should be cleared! Never an empty array!
                     \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcName, $_params, $this);
                 }
             }
             // Delete cache for selected pages:
             if (is_array($list_cache)) {
                 foreach ($list_cache as $pageId) {
                     $tagsToFlush[] = 'pageId_' . (int) $pageId;
                 }
             }
         }
     }
     // flush cache by tag
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr(strtolower($cacheCmd), 'cachetag:')) {
         $cacheTag = substr($cacheCmd, 9);
         $tagsToFlush[] = $cacheTag;
     }
     // process caching framwork operations
     if (count($tagsToFlush) > 0) {
         /** @var $pageCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
         $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
         /** @var $pageSectionCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
         $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
         foreach ($tagsToFlush as $tag) {
             $pageCache->flushByTag($tag);
             $pageSectionCache->flushByTag($tag);
         }
     }
     // Call post processing function for clear-cache:
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'])) {
         $_params = array('cacheCmd' => strtolower($cacheCmd));
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'] as $_funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($_funcRef, $_params, $this);
         }
     }
 }