Story #54991 ยป caching_framework.patch
typo3/sysext/core/Classes/Cache/CacheManager.php | ||
---|---|---|
protected $cacheConfigurations = array();
|
||
/**
|
||
* used to flush caches of a specific group
|
||
* is an associative array containing the group identifier as key
|
||
* and the identifier as an array within that group
|
||
* groups are set via the cache configurations of each cache
|
||
* @var array
|
||
*/
|
||
protected $cacheGroups = array();
|
||
/**
|
||
* @var array Default cache configuration as fallback
|
||
*/
|
||
protected $defaultCacheConfiguration = array(
|
||
'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend',
|
||
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\Typo3DatabaseBackend',
|
||
'options' => array()
|
||
'options' => array(),
|
||
'groups' => array('unassigned')
|
||
);
|
||
/**
|
||
... | ... | |
}
|
||
/**
|
||
* Flushes all registered caches of a specific group
|
||
*
|
||
* @param string $groupIdentifier
|
||
* @return void
|
||
* @api
|
||
*/
|
||
public function flushCachesInGroup($groupIdentifier) {
|
||
$this->createAllCaches();
|
||
if (isset($this->cacheGroups[$groupIdentifier])) {
|
||
foreach ($this->cacheGroups[$groupIdentifier] as $cacheIdentifier) {
|
||
if (isset($this->caches[$cacheIdentifier])) {
|
||
$this->caches[$cacheIdentifier]->flush();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Flushes entries tagged by the specified tag of all registered
|
||
* caches of a specific group.
|
||
*
|
||
* @param string $groupIdentifier
|
||
* @param string $tag Tag to search for
|
||
* @return void
|
||
* @api
|
||
*/
|
||
public function flushCachesInGroupByTag($groupIdentifier, $tag) {
|
||
$this->createAllCaches();
|
||
if (isset($this->cacheGroups[$groupIdentifier])) {
|
||
foreach ($this->cacheGroups[$groupIdentifier] as $cacheIdentifier) {
|
||
if (isset($this->caches[$cacheIdentifier])) {
|
||
$this->caches[$cacheIdentifier]->flushByTag($tag);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Flushes entries tagged by the specified tag of all registered
|
||
* caches.
|
||
*
|
||
... | ... | |
*
|
||
* @param string $identifier
|
||
* @return void
|
||
* @throws \TYPO3\CMS\Core\Cache\Exception\InvalidCacheException when the groups parameter is not set
|
||
*/
|
||
protected function createCache($identifier) {
|
||
if (isset($this->cacheConfigurations[$identifier]['frontend'])) {
|
||
... | ... | |
} else {
|
||
$backendOptions = $this->defaultCacheConfiguration['options'];
|
||
}
|
||
// add the cache to the groups that it should be attached, or use the default ones
|
||
if (isset($this->cacheConfigurations[$identifier]['groups']) && is_array($this->cacheConfigurations[$identifier]['groups'])) {
|
||
$assignedGroups = $this->cacheConfigurations[$identifier]['groups'];
|
||
} else {
|
||
$assignedGroups = $this->defaultCacheConfiguration['groups'];
|
||
}
|
||
foreach ($assignedGroups as $groupIdentifier) {
|
||
if (!is_array($this->cacheGroups[$groupIdentifier])) {
|
||
$this->cacheGroups[$groupIdentifier] = array();
|
||
}
|
||
$this->cacheGroups[$groupIdentifier][] = $identifier;
|
||
}
|
||
$this->cacheFactory->create($identifier, $frontend, $backend, $backendOptions);
|
||
}
|
||
typo3/sysext/core/Classes/DataHandling/DataHandler.php | ||
---|---|---|
/**
|
||
* 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='pages'
|
||
* Clears cache for all pages and page-based caches inside the cache manager.
|
||
* 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='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).
|
||
* The following cache_* are intentionally not cleared by 'all'
|
||
*
|
||
* $cacheCmd='cacheTag:[string]': Flush page and pagesection cache by given tag
|
||
* - 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.
|
||
* - all caches inside the cache manager that are inside the group "system"
|
||
* - they are only needed to build up the core system and templates,
|
||
* use "temp_cached" or "system" to do that
|
||
*
|
||
* $cacheCmd=[integer]
|
||
* Clears cache for the page pointed to by $cacheCmd (an integer).
|
||
*
|
||
* $cacheCmd='cacheId:[string]': Removes cache identifier from page and page section cache
|
||
* $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
|
||
* GeneralUtility::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
|
||
* @throws \RuntimeException
|
||
*/
|
||
public function clear_cacheCmd($cacheCmd) {
|
||
if (is_object($this->BE_USER)) {
|
||
... | ... | |
switch (strtolower($cacheCmd)) {
|
||
case 'pages':
|
||
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.pages')) {
|
||
$this->internal_clearPageCache();
|
||
$GLOBALS['typo3CacheManager']->flushCachesInGroup('pages');
|
||
}
|
||
break;
|
||
case 'all':
|
||
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
|
||
// Clear all caching framework caches
|
||
$GLOBALS['typo3CacheManager']->flushCaches();
|
||
$GLOBALS['typo3CacheManager']->flushCachesInGroup('pages');
|
||
$GLOBALS['typo3CacheManager']->flushCachesInGroup('unassigned');
|
||
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
|
||
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_treelist');
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
}
|
||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
|
||
break;
|
||
case 'temp_cached':
|
||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::removeCacheFiles();
|
||
case 'system':
|
||
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.system') || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
|
||
$GLOBALS['typo3CacheManager']->flushCachesInGroup('system');
|
||
}
|
||
break;
|
||
}
|
||
$tagsToFlush = array();
|
||
// Clear cache for a page ID!
|
||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($cacheCmd)) {
|
||
... | ... | |
}
|
||
// 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');
|
||
/** @var $hashCache \TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend */
|
||
$hashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
foreach ($tagsToFlush as $tag) {
|
||
$pageCache->flushByTag($tag);
|
||
$pageSectionCache->flushByTag($tag);
|
||
$hashCache->flushByTag($tag);
|
||
$GLOBALS['typo3CacheManager']->flushCachesInGroupByTag('pages', $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));
|
||
... | ... | |
*
|
||
* @return void
|
||
* @todo Define visibility
|
||
* @deprecated since TYPO3 CMS 6.2, remove two versions later
|
||
*/
|
||
public function internal_clearPageCache() {
|
||
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_pages')->flush();
|
||
}
|
||
GeneralUtility::logDeprecatedFunction('The DataHandler clearPageCache method is deprecated, use the cache manager directly.');
|
||
$GLOBALS['typo3CacheManager']->flushGroups('pages');
|
||
}
|
||
/**
|
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php | ||
---|---|---|
}
|
||
/**
|
||
* Remove cache files from php code cache, tagged with 'core'
|
||
* Remove cache files from php code cache, grouped by 'system'
|
||
*
|
||
* This removes the following cache entries:
|
||
* - autoloader cache registry
|
||
... | ... | |
* @return void
|
||
*/
|
||
static public function removeCacheFiles() {
|
||
/** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
|
||
$codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
|
||
$codeCache->flush();
|
||
$GLOBALS['typo3CacheManager']->flushCachesInGroup('system');
|
||
}
|
||
/**
|
typo3/sysext/core/Configuration/DefaultConfiguration.php | ||
---|---|---|
'cache_core' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\PhpFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend',
|
||
'options' => array()
|
||
'options' => array(
|
||
'defaultLifetime' => 0,
|
||
),
|
||
'groups' => array('system')
|
||
),
|
||
'cache_classes' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\StringFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend',
|
||
'options' => array()
|
||
'options' => array(
|
||
'defaultLifetime' => 0,
|
||
),
|
||
'groups' => array('system')
|
||
),
|
||
'cache_hash' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
|
||
'options' => array()
|
||
'options' => array(),
|
||
'groups' => array('pages')
|
||
),
|
||
'cache_pages' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
|
||
'options' => array(
|
||
'compression' => TRUE
|
||
)
|
||
),
|
||
'groups' => array('pages')
|
||
),
|
||
'cache_pagesection' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
|
||
'options' => array(
|
||
'compression' => TRUE
|
||
)
|
||
),
|
||
'groups' => array('pages')
|
||
),
|
||
'cache_phpcode' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\PhpFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\FileBackend',
|
||
'options' => array()
|
||
'options' => array(
|
||
'defaultLifetime' => 0,
|
||
),
|
||
'groups' => array('system')
|
||
),
|
||
'cache_runtime' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend',
|
||
'options' => array()
|
||
'options' => array(),
|
||
'groups' => array()
|
||
),
|
||
'cache_rootline' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend',
|
||
'options' => array()
|
||
'options' => array(),
|
||
'groups' => array('pages')
|
||
),
|
||
't3lib_l10n' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
'backend' => 'TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend',
|
||
'options' => array(),
|
||
'options' => array(
|
||
'defaultLifetime' => 0,
|
||
),
|
||
'groups' => array('system')
|
||
),
|
||
'extbase_object' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
... | ... | |
'options' => array(
|
||
'defaultLifetime' => 0,
|
||
),
|
||
'groups' => array('system')
|
||
),
|
||
'extbase_reflection' => array(
|
||
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
|
||
... | ... | |
'options' => array(
|
||
'defaultLifetime' => 0,
|
||
),
|
||
'groups' => array('system')
|
||
),
|
||
),
|
||
),
|
typo3/sysext/dbal/ext_localconf.php | ||
---|---|---|
// Register caches if not already done in localconf.php or a previously loaded extension.
|
||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal'])) {
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal'] = array(
|
||
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend'
|
||
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\TransientMemoryBackend',
|
||
'groups' => array()
|
||
);
|
||
}
|
typo3/sysext/extbase/ext_localconf.php | ||
---|---|---|
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extbase') . 'Classes/Utility/ExtensionUtility.php';
|
||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'])) {
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(
|
||
'groups' => array('system')
|
||
);
|
||
}
|
||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'])) {
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(
|
||
'groups' => array('system')
|
||
);
|
||
}
|
||
// We need to set the default implementation for Storage Backend & Query Settings
|
typo3/sysext/fluid/ext_localconf.php | ||
---|---|---|
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['fluid_template'])) {
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['fluid_template'] = array(
|
||
'backend' => 'TYPO3\\CMS\\Core\\Cache\\Backend\\FileBackend',
|
||
'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend'
|
||
'frontend' => 'TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend',
|
||
'groups' => array('system')
|
||
);
|
||
}
|
typo3/sysext/install/Classes/Service/SqlExpectedSchemaService.php | ||
---|---|---|
*/
|
||
public function getCachingFrameworkRequiredDatabaseSchema() {
|
||
$cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(
|
||
'groups' => array('system')
|
||
);
|
||
$extbaseObjectFakeName = uniqid('extbase_object');
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array(
|
||
'groups' => array('system')
|
||
);
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(
|
||
'groups' => array('system')
|
||
);
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(
|
||
'groups' => array('system')
|
||
);
|
||
/** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
|
||
$cacheManager = $GLOBALS['typo3CacheManager'];
|
||
$cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
|
typo3/sysext/workspaces/ext_localconf.php | ||
---|---|---|
// Register workspaces cache if not already done in localconf.php or a previously loaded extension.
|
||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['workspaces_cache'])) {
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['workspaces_cache'] = array();
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['workspaces_cache'] = array(
|
||
'groups' => array('pages')
|
||
);
|
||
}
|
||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('options.workspaces.considerReferences = 1');
|