Bug #20737 » 11505_re-implement_db_caching.diff
t3lib/config_default.php (Arbeitskopie) | ||
---|---|---|
'reverseProxyPrefix' => '', // String: optional prefix to be added to the internal URL (SCRIPT_NAME and REQUEST_URI).
|
||
'reverseProxySSL' => '', // String: '*' or list of IP addresses of proxies that use SSL (https) for the connection to the client, but an unencrypted connection (http) to the server. If '*' all proxies defined in SYS[reverseProxyIP] use SSL.
|
||
'reverseProxyPrefixSSL' => '', // String: prefix to be added to the internal URL (SCRIPT_NAME and REQUEST_URI) when accessing the server via an SSL proxy. This setting overrides SYS[reverseProxyPrefix].
|
||
'caching' => array(
|
||
'defaultFrontend' => 't3lib_cache_frontend_VariableFrontend',
|
||
'defaultBackend' => 't3lib_cache_backend_FileBackend',
|
||
'cacheFrontends' => array(
|
||
't3lib_cache_frontend_VariableFrontend' => 't3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php:t3lib_cache_frontend_VariableFrontend',
|
||
't3lib_cache_frontend_StringFrontend' => 't3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontend.php:t3lib_cache_frontend_StringFrontend'
|
||
),
|
||
'cacheBackends' => array(
|
||
't3lib_cache_backend_DbBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php:t3lib_cache_backend_DbBackend',
|
||
't3lib_cache_backend_FileBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_filebackend.php:t3lib_cache_backend_FileBackend',
|
||
't3lib_cache_backend_GlobalsBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_globalsbackend.php:t3lib_cache_backend_GlobalsBackend',
|
||
't3lib_cache_backend_MemcachedBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_memcachedbackend.php:t3lib_cache_backend_MemcachedBackend',
|
||
't3lib_cache_backend_ApcBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_apcbackend.php:t3lib_cache_backend_ApcBackend',
|
||
't3lib_cache_backend_NullBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_nullbackend.php:t3lib_cache_backend_NullBackend'
|
||
),
|
||
'cacheConfigurations' => array(
|
||
'cache_hash' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_hash'
|
||
)
|
||
),
|
||
'cache_pages' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_pages'
|
||
)
|
||
),
|
||
'cache_pagesection' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_pagesection'
|
||
)
|
||
)
|
||
/*
|
||
For memcached, use:
|
||
=============
|
||
'cache_pages' => array(
|
||
'backend' => 't3lib_cache_backend_MemcachedBackend',
|
||
'options' => array(
|
||
'servers' => array('localhost:11211', 'otherhost:11211', 'thirdhost:11211'), // port is mandatory!
|
||
)
|
||
),
|
||
=============
|
||
You need to have memcached installed as a daemon and also as a PHP extension!
|
||
*/
|
||
)
|
||
)
|
||
'useCachingFramework' => 0, // Boolean: Enable this if you want to use the caching framework
|
||
),
|
||
'EXT' => Array ( // Options related to the Extension Management
|
||
'noEdit' => 1, // Boolean: If set, the Extension Manager does NOT allow extension files to be edited! (Otherwise both local and global extensions can be edited.)
|
||
... | ... | |
if (!@is_file(PATH_typo3conf.'localconf.php')) die('localconf.php is not found!');
|
||
require(PATH_typo3conf.'localconf.php');
|
||
$GLOBALS['USE_CACHING_FRAMEWORK'] = FALSE;
|
||
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['useCachingFramework']==1) {
|
||
$GLOBALS['USE_CACHING_FRAMEWORK'] = TRUE;
|
||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching'] = array(
|
||
'defaultFrontend' => 't3lib_cache_frontend_VariableFrontend',
|
||
'defaultBackend' => 't3lib_cache_backend_FileBackend',
|
||
'cacheFrontends' => array(
|
||
't3lib_cache_frontend_VariableFrontend' => 't3lib/cache/frontend/class.t3lib_cache_frontend_variablefrontend.php:t3lib_cache_frontend_VariableFrontend',
|
||
't3lib_cache_frontend_StringFrontend' => 't3lib/cache/frontend/class.t3lib_cache_frontend_stringfrontend.php:t3lib_cache_frontend_StringFrontend'
|
||
),
|
||
'cacheBackends' => array(
|
||
't3lib_cache_backend_DbBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php:t3lib_cache_backend_DbBackend',
|
||
't3lib_cache_backend_FileBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_filebackend.php:t3lib_cache_backend_FileBackend',
|
||
't3lib_cache_backend_GlobalsBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_globalsbackend.php:t3lib_cache_backend_GlobalsBackend',
|
||
't3lib_cache_backend_MemcachedBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_memcachedbackend.php:t3lib_cache_backend_MemcachedBackend',
|
||
't3lib_cache_backend_ApcBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_apcbackend.php:t3lib_cache_backend_ApcBackend',
|
||
't3lib_cache_backend_NullBackend' => 't3lib/cache/backend/class.t3lib_cache_backend_nullbackend.php:t3lib_cache_backend_NullBackend'
|
||
),
|
||
'cacheConfigurations' => array(
|
||
'cache_hash' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_hash'
|
||
)
|
||
),
|
||
'cache_pages' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_pages'
|
||
)
|
||
),
|
||
'cache_pagesection' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_pagesection'
|
||
)
|
||
)
|
||
/*
|
||
For memcached, use:
|
||
=============
|
||
'cache_pages' => array(
|
||
'backend' => 't3lib_cache_backend_MemcachedBackend',
|
||
'options' => array(
|
||
'servers' => array('localhost:11211', 'otherhost:11211', 'thirdhost:11211'), // port is mandatory!
|
||
)
|
||
),
|
||
=============
|
||
You need to have memcached installed as a daemon and also as a PHP extension!
|
||
*/
|
||
)
|
||
);
|
||
}
|
||
// Defining the database setup as constants
|
||
define('TYPO3_db', $typo_db);
|
||
define('TYPO3_db_username', $typo_db_username);
|
t3lib/stddb/tables.sql (Arbeitskopie) | ||
---|---|---|
identifier varchar(250) DEFAULT '' NOT NULL,
|
||
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||
content mediumtext,
|
||
ident varchar(20) DEFAULT '' NOT NULL,
|
||
tags mediumtext,
|
||
lifetime int(11) unsigned DEFAULT '0' NOT NULL,
|
||
PRIMARY KEY (id),
|
t3lib/class.t3lib_tstemplate.php (Arbeitskopie) | ||
---|---|---|
*/
|
||
function getCurrentPageData() {
|
||
$currentPageData = false;
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'content', 'cache_pagesection', 'page_id='.intval($GLOBALS['TSFE']->id).' AND mpvar_hash='.t3lib_div::md5int($GLOBALS['TSFE']->MP));
|
||
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
$currentPageData = unserialize($row['content']);
|
||
}
|
||
} else {
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
$cacheEntry = $pageSectionCache->get(
|
||
intval($GLOBALS['TSFE']->id) . '_' . t3lib_div::md5int($GLOBALS['TSFE']->MP)
|
||
);
|
||
$cacheEntry = $pageSectionCache->get(
|
||
intval($GLOBALS['TSFE']->id) . '_' . t3lib_div::md5int($GLOBALS['TSFE']->MP)
|
||
);
|
||
if ($cacheEntry) {
|
||
$currentPageData = unserialize($cacheEntry);
|
||
if ($cacheEntry) {
|
||
$currentPageData = unserialize($cacheEntry);
|
||
}
|
||
}
|
||
return $currentPageData; // 2008-02-03 / Stucki: Notice that $this->currentPageData is not used anymore!
|
||
... | ... | |
unset($cc['match']);
|
||
if (!$isCached && !$this->simulationHiddenOrTime && !$GLOBALS['TSFE']->no_cache) { // Only save the data if we're not simulating by hidden/starttime/endtime
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
$mpvarHash = t3lib_div::md5int($GLOBALS['TSFE']->MP);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$dbFields = array(
|
||
'content' => serialize($cc),
|
||
'crdate' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvarHash, $dbFields);
|
||
if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
|
||
$dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
|
||
$dbFields['mpvar_hash'] = $mpvarHash;
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
|
||
}
|
||
} else {
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
$pageSectionCache->set(
|
||
intval($GLOBALS['TSFE']->id) . '_' . $mpvarHash,
|
||
serialize($cc),
|
||
array(
|
||
'pageId_' . intval($GLOBALS['TSFE']->id),
|
||
'mpvarHash_' . $mpvarHash
|
||
)
|
||
);
|
||
$pageSectionCache->set(
|
||
intval($GLOBALS['TSFE']->id) . '_' . $mpvarHash,
|
||
serialize($cc),
|
||
array(
|
||
'pageId_' . intval($GLOBALS['TSFE']->id),
|
||
'mpvarHash_' . $mpvarHash
|
||
)
|
||
);
|
||
}
|
||
}
|
||
// If everything OK.
|
||
if ($this->rootId && $this->rootLine && $this->setup) {
|
t3lib/class.t3lib_befunc.php (Arbeitskopie) | ||
---|---|---|
* @return void
|
||
*/
|
||
public static function storeHash($hash, $data, $ident) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set(
|
||
$hash,
|
||
$data,
|
||
array('ident_' . $ident),
|
||
0 // unlimited lifetime
|
||
);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$insertFields = array(
|
||
'identifier' => $hash,
|
||
'content' => $data,
|
||
'ident' => $ident,
|
||
'crdate' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'identifier='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
|
||
} else {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set(
|
||
$hash,
|
||
$data,
|
||
array('ident_' . $ident),
|
||
0 // unlimited lifetime
|
||
);
|
||
}
|
||
}
|
||
/**
|
||
... | ... | |
* @param string The hash-string which was used to store the data value
|
||
* @return string
|
||
*/
|
||
public static function getHash($hash) {
|
||
$hashContent = null;
|
||
public static function getHash($hash, $expTime = 0) {
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$expTime = intval($expTime);
|
||
if ($expTime) {
|
||
$whereAdd = ' AND crdate > '.(time()-$expTime);
|
||
}
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'identifier='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').$whereAdd);
|
||
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
return (is_array($row) ? $row['content'] : null);
|
||
} else {
|
||
$hashContent = null;
|
||
if ($cacheEntry) {
|
||
$hashContent = $cacheEntry;
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
if ($cacheEntry) {
|
||
$hashContent = $cacheEntry;
|
||
}
|
||
return $hashContent;
|
||
}
|
||
return $hashContent;
|
||
}
|
||
/*******************************************
|
||
*
|
||
* TypoScript related
|
||
... | ... | |
$failed[] = $configuredServer;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (count($failed) > 0) {
|
||
$warnings['memcached'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.memcache_not_usable') . '<br/>' .
|
||
$warnings['memcached'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.memcache_not_usable') . '<br/>' .
|
||
implode(', ', $failed);
|
||
}
|
||
}
|
t3lib/class.t3lib_page.php (Arbeitskopie) | ||
---|---|---|
* @return string The "content" field of the "cache_hash" cache entry.
|
||
* @see tslib_TStemplate::start(), storeHash()
|
||
*/
|
||
public static function getHash($hash) {
|
||
public static function getHash($hash, $expTime = 0) {
|
||
$hashContent = null;
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$expTime = intval($expTime);
|
||
if ($expTime) {
|
||
$whereAdd = ' AND crdate > '.($GLOBALS['ACCESS_TIME']-$expTime);
|
||
}
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash', 'identifier='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').$whereAdd);
|
||
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
if ($row) {
|
||
$hashContent= $row['content'];
|
||
}
|
||
} else {
|
||
if ($cacheEntry) {
|
||
$hashContent = $cacheEntry;
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
if ($cacheEntry) {
|
||
$hashContent = $cacheEntry;
|
||
}
|
||
}
|
||
return $hashContent;
|
||
}
|
||
... | ... | |
* @see tslib_TStemplate::start(), getHash()
|
||
*/
|
||
public static function storeHash($hash, $data, $ident, $lifetime = 0) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set(
|
||
$hash,
|
||
$data,
|
||
array('ident_' . $ident),
|
||
$lifetime
|
||
);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$insertFields = array(
|
||
'identifier' => $hash,
|
||
'content' => $data,
|
||
'ident' => $ident,
|
||
'crdate' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'identifier='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
|
||
} else {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set(
|
||
$hash,
|
||
$data,
|
||
array('ident_' . $ident),
|
||
$lifetime
|
||
);
|
||
}
|
||
}
|
||
/**
|
t3lib/class.t3lib_div.php (Arbeitskopie) | ||
---|---|---|
$array = $firstLevelCache[$identifier];
|
||
} else {
|
||
// look up in second level cache
|
||
$array = $GLOBALS['typo3CacheManager']->getCache('cache_hash')->get($identifier);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$cacheContent = t3lib_pageSelect::getHash($identifier, 0);
|
||
$array = unserialize($cacheContent);
|
||
} else {
|
||
$array = $GLOBALS['typo3CacheManager']->getCache('cache_hash')->get($identifier);
|
||
}
|
||
if ($array === false) {
|
||
$array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
|
||
// store content in second level cache
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set($identifier, $array, array('ident_xml2array'), 0);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
t3lib_pageSelect::storeHash($identifier, serialize($array), 'ident_xml2array');
|
||
} else {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set($identifier, $array, array('ident_xml2array'), 0);
|
||
}
|
||
}
|
||
// store content in first level cache
|
||
$firstLevelCache[$identifier] = $array;
|
t3lib/class.t3lib_tsfebeuserauth.php (Arbeitskopie) | ||
---|---|---|
*/
|
||
public function initializeAdminPanel() {
|
||
$this->extAdminConfig = $this->getTSConfigProp('admPanel');
|
||
if (isset($this->extAdminConfig['enable.'])) {
|
||
foreach($this->extAdminConfig['enable.'] as $key => $value) {
|
||
if ($value) {
|
||
... | ... | |
* @return integer The number of pages for this page in the table "cache_pages"
|
||
*/
|
||
public function extGetNumberOfCachedPages($pageId) {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
|
||
$pageCacheEntries = $pageCache->getByTag('pageId_' . (int) $pageId);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', 'page_id='.intval($pageId));
|
||
list($num) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
|
||
return $num;
|
||
} else {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
|
||
$pageCacheEntries = $pageCache->getByTag('pageId_' . (int) $pageId);
|
||
return count($pageCacheEntries);
|
||
return count($pageCacheEntries);
|
||
}
|
||
}
|
||
t3lib/class.t3lib_userauthgroup.php (Arbeitskopie) | ||
---|---|---|
$this->userTS_text = implode(chr(10).'[GLOBAL]'.chr(10),$this->TSdataArray); // Imploding with "[global]" will make sure that non-ended confinements with braces are ignored.
|
||
$hash = md5('userTS:'.$this->userTS_text);
|
||
$cachedContent = t3lib_BEfunc::getHash($hash);
|
||
if (isset($cachedContent) && !$this->userTS_dontGetCached) {
|
||
$this->userTS = unserialize($cachedContent);
|
||
} else {
|
t3lib/class.t3lib_tcemain.php (Arbeitskopie) | ||
---|---|---|
// Delete cache for selected pages:
|
||
if (is_array($list_cache)) {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pagesection'
|
||
);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages','page_id IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($list_cache)).')');
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', 'page_id IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($list_cache)).')');
|
||
$pageIds = $GLOBALS['TYPO3_DB']->cleanIntArray($list_cache);
|
||
foreach ($pageIds as $pageId) {
|
||
$pageCache->flushByTag('pageId_' . $pageId);
|
||
$pageSectionCache->flushByTag('pageId_' . $pageId);
|
||
} else {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pagesection'
|
||
);
|
||
$pageIds = $GLOBALS['TYPO3_DB']->cleanIntArray($list_cache);
|
||
foreach ($pageIds as $pageId) {
|
||
$pageCache->flushByTag('pageId_' . $pageId);
|
||
$pageSectionCache->flushByTag('pageId_' . $pageId);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
case 'all':
|
||
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
|
||
// clear all caches that use the t3lib_cache framework
|
||
$GLOBALS['typo3CacheManager']->flushCaches();
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', '');
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', '');
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection','');
|
||
}
|
||
$this->internal_clearPageCache();
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash','');
|
||
} else {
|
||
// clear all caches that use the t3lib_cache framework
|
||
$GLOBALS['typo3CacheManager']->flushCaches();
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', '');
|
||
}
|
||
}
|
||
// Clearing additional cache tables:
|
||
... | ... | |
// Delete cache for selected pages:
|
||
if (is_array($list_cache)) {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pagesection'
|
||
);
|
||
foreach ($list_cache as $pageId) {
|
||
$pageCache->flushByTag('pageId_' . (int) $pageId);
|
||
$pageSectionCache->flushByTag('pageId_' . (int) $pageId);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages','page_id IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($list_cache)).')');
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', 'page_id IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($list_cache)).')'); // Originally, cache_pagesection was not cleared with cache_pages!
|
||
} else {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pagesection'
|
||
);
|
||
foreach ($list_cache as $pageId) {
|
||
$pageCache->flushByTag('pageId_' . (int) $pageId);
|
||
$pageSectionCache->flushByTag('pageId_' . (int) $pageId);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
* @return void
|
||
*/
|
||
function internal_clearPageCache() {
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_pages')->flush();
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageCacheToExternalFiles']) {
|
||
$cacheDir = PATH_site.'typo3temp/cache_pages';
|
||
$retVal = t3lib_div::rmdir($cacheDir,true);
|
||
if (!$retVal) {
|
||
t3lib_div::sysLog('Could not remove page cache files in "'.$cacheDir.'"','Core/t3lib_tcemain',2);
|
||
}
|
||
}
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages','');
|
||
}
|
||
} else {
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_pages')->flush();
|
||
}
|
||
}
|
||
}
|
||
/**
|
typo3/init.php (Arbeitskopie) | ||
---|---|---|
// Initializing the Caching System
|
||
// ***********************************
|
||
$typo3CacheManager = t3lib_div::makeInstance('t3lib_cache_Manager');
|
||
$typo3CacheFactory = t3lib_div::makeInstance('t3lib_cache_Factory');
|
||
$typo3CacheFactory->setCacheManager($typo3CacheManager);
|
||
if ($GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$typo3CacheManager = t3lib_div::makeInstance('t3lib_cache_Manager');
|
||
$typo3CacheFactory = t3lib_div::makeInstance('t3lib_cache_Factory');
|
||
$typo3CacheFactory->setCacheManager($typo3CacheManager);
|
||
t3lib_cache::initPageCache();
|
||
t3lib_cache::initPageSectionCache();
|
||
t3lib_cache::initContentHashCache();
|
||
unset($cacheFactoryClass);
|
||
t3lib_cache::initPageCache();
|
||
t3lib_cache::initPageSectionCache();
|
||
t3lib_cache::initContentHashCache();
|
||
unset($cacheFactoryClass);
|
||
}
|
||
// *************************
|
||
// CLI dispatch processing
|
||
// *************************
|
typo3/sysext/cms/ext_tables.sql (Arbeitskopie) | ||
---|---|---|
id int(11) unsigned NOT NULL auto_increment,
|
||
identifier varchar(250) DEFAULT '' NOT NULL,
|
||
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||
page_id int(11) unsigned DEFAULT '0' NOT NULL,
|
||
reg1 int(11) unsigned DEFAULT '0' NOT NULL,
|
||
content mediumtext,
|
||
tags mediumtext,
|
||
lifetime int(11) unsigned DEFAULT '0' NOT NULL,
|
||
PRIMARY KEY (id),
|
||
KEY cache_id (identifier)
|
||
temp_content int(1) DEFAULT '0' NOT NULL,
|
||
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||
expires int(10) unsigned DEFAULT '0' NOT NULL,
|
||
cache_data mediumblob,
|
||
KEY page_id (page_id),
|
||
KEY sel (identifier,page_id),
|
||
PRIMARY KEY (id)
|
||
) ENGINE=InnoDB;
|
||
... | ... | |
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||
content mediumtext,
|
||
tags mediumtext,
|
||
lifetime int(11) unsigned DEFAULT '0' NOT NULL,
|
||
lifetime int(11) unsigned DEFAULT '0' NOT NULL,
|
||
page_id int(11) unsigned DEFAULT '0' NOT NULL,
|
||
mpvar_hash int(11) unsigned DEFAULT '0' NOT NULL,
|
||
PRIMARY KEY (id),
|
||
KEY cache_id (identifier)
|
||
KEY cache_id (identifier),
|
||
KEY sel (page_id,mpvar_hash)
|
||
) ENGINE=InnoDB;
|
||
typo3/sysext/cms/tslib/class.tslib_fe.php (Arbeitskopie) | ||
---|---|---|
}
|
||
}
|
||
$this->initCaches();
|
||
if ($GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$this->initCaches();
|
||
}
|
||
}
|
||
/**
|
||
... | ... | |
$this->releasePageGenerationLock($this->pages_lockObj);
|
||
$this->config = (array)unserialize($row['cache_data']); // Fetches the lowlevel config stored with the cached data
|
||
$this->content = $row['HTML']; // Getting the content
|
||
$this->content = $row['content']; // Getting the content
|
||
$this->tempContent = $row['temp_content']; // Flag for temp content
|
||
$this->cacheContentFlag = 1; // Setting flag, so we know, that some cached content has been loaded
|
||
$this->cacheExpires = $row['expires'];
|
||
... | ... | |
* @return array Cached row, if any. Otherwise void.
|
||
*/
|
||
function getFromCache_queryRow() {
|
||
$GLOBALS['TT']->push('Cache Query', '');
|
||
$cachedPage = $this->pageCache->get($this->newHash);
|
||
$GLOBALS['TT']->pull();
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$GLOBALS['TT']->push('Cache Query','');
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'S.*',
|
||
'cache_pages S,pages P',
|
||
'S.identifier='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages').'
|
||
AND S.page_id=P.uid
|
||
AND S.expires > '.intval($GLOBALS['ACCESS_TIME']).'
|
||
AND P.deleted=0
|
||
AND P.hidden=0
|
||
AND P.starttime<='.intval($GLOBALS['ACCESS_TIME']).'
|
||
AND (P.endtime=0 OR P.endtime>'.intval($GLOBALS['ACCESS_TIME']).')'
|
||
);
|
||
$GLOBALS['TT']->pull();
|
||
return $cachedPage;
|
||
if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
$this->pageCachePostProcess($row,'get');
|
||
}
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
} else {
|
||
$GLOBALS['TT']->push('Cache Query', '');
|
||
$row = $this->pageCache->get($this->newHash);
|
||
$GLOBALS['TT']->pull();
|
||
}
|
||
return $row;
|
||
}
|
||
/**
|
||
... | ... | |
* @see realPageCacheContent(), tempPageCacheContent()
|
||
*/
|
||
function setPageCacheContent($content, $data, $expirationTstamp) {
|
||
$cacheData = array(
|
||
'hash' => $this->newHash,
|
||
'page_id' => $this->id,
|
||
'HTML' => $content,
|
||
'temp_content' => $this->tempContent,
|
||
'cache_data' => serialize($data),
|
||
'expires' => $expirationTstamp,
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$this->cacheExpires = $expirationTstamp;
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$this->clearPageCacheContent();
|
||
$insertFields = array(
|
||
'identifier' => $this->newHash,
|
||
'page_id' => $this->id,
|
||
'content' => $content,
|
||
'temp_content' => $this->tempContent,
|
||
'cache_data' => serialize($data),
|
||
'expires' => $expirationTstamp,
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$this->pageCacheTags[] = 'pageId_' . $cacheData['page_id'];
|
||
$this->cacheExpires = $expirationTstamp;
|
||
if ($this->page_cache_reg1) {
|
||
$reg1 = intval($this->page_cache_reg1);
|
||
if ($this->page_cache_reg1) {
|
||
$insertFields['reg1'] = intval($this->page_cache_reg1);
|
||
}
|
||
$this->pageCachePostProcess($insertFields,'set');
|
||
$cacheData['reg1'] = $reg1;
|
||
$this->pageCacheTags[] = 'reg1_' . $reg1;
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pages', $insertFields);
|
||
} else {
|
||
$cacheData = array(
|
||
'identifier' => $this->newHash,
|
||
'page_id' => $this->id,
|
||
'content' => $content,
|
||
'temp_content' => $this->tempContent,
|
||
'cache_data' => serialize($data),
|
||
'expires' => $expirationTstamp,
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$this->cacheExpires = $expirationTstamp;
|
||
$this->pageCacheTags[] = 'pageId_' . $cacheData['page_id'];
|
||
if ($this->page_cache_reg1) {
|
||
$reg1 = intval($this->page_cache_reg1);
|
||
$cacheData['reg1'] = $reg1;
|
||
$this->pageCacheTags[] = 'reg1_' . $reg1;
|
||
}
|
||
$this->pageCache->set(
|
||
$this->newHash,
|
||
$cacheData,
|
||
$this->pageCacheTags,
|
||
$expirationTstamp - $GLOBALS['EXEC_TIME']
|
||
);
|
||
}
|
||
$this->pageCache->set(
|
||
$cacheData['hash'],
|
||
$cacheData,
|
||
$this->pageCacheTags,
|
||
$cacheData['expires'] - $GLOBALS['EXEC_TIME']
|
||
);
|
||
}
|
||
/**
|
||
... | ... | |
* @return void
|
||
*/
|
||
function clearPageCacheContent() {
|
||
$this->pageCache->remove($this->newHash);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'identifier='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages'));
|
||
} else {
|
||
$this->pageCache->remove($this->newHash);
|
||
}
|
||
}
|
||
/**
|
||
* Post processing page cache rows for both get and set.
|
||
*
|
||
* @param array Input "cache_pages" row, passed by reference!
|
||
* @param string Type of operation, either "get" or "set"
|
||
* @return void
|
||
*/
|
||
function pageCachePostProcess(&$row,$type) {
|
||
if ($this->TYPO3_CONF_VARS['FE']['pageCacheToExternalFiles']) {
|
||
$cacheFileName = PATH_site.'typo3temp/cache_pages/'.$row['hash']{0}.$row['hash']{1}.'/'.$row['hash'].'.html';
|
||
switch((string)$type) {
|
||
case 'get':
|
||
$row['content'] = @is_file($cacheFileName) ? t3lib_div::getUrl($cacheFileName) : '<!-- CACHING ERROR, sorry -->';
|
||
break;
|
||
case 'set':
|
||
t3lib_div::writeFileToTypo3tempDir($cacheFileName,$row['content']);
|
||
$row['content'] = '';
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Clears cache content for a list of page ids
|
||
*
|
||
... | ... | |
* @return void
|
||
*/
|
||
function clearPageCacheContent_pidList($pidList) {
|
||
$pageIds = t3lib_div::trimExplode(',', $pidList);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($pidList).')');
|
||
} else {
|
||
$pageIds = t3lib_div::trimExplode(',', $pidList);
|
||
foreach ($pageIds as $pageId) {
|
||
$this->pageCache->flushByTag('pageId_' . (int) $pageId);
|
||
foreach ($pageIds as $pageId) {
|
||
$this->pageCache->flushByTag('pageId_' . (int) $pageId);
|
||
}
|
||
}
|
||
}
|
||
typo3/sysext/cms/tslib/class.tslib_content.php (Arbeitskopie) | ||
---|---|---|
$this->substMarkerCache[$storeKey] = $storeArr;
|
||
// Storing the cached data:
|
||
$GLOBALS['TSFE']->sys_page->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached');
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
$storeArrDat = serialize($storeArr);
|
||
}
|
||
$GLOBALS['TSFE']->sys_page->storeHash($storeKey, $storeArrDat, 'substMarkArrayCached');
|
||
$GLOBALS['TT']->setTSlogMessage('Parsing',0);
|
||
} else {
|
||
// Unserializing
|
||
$storeArr = unserialize($storeArrDat);
|
||
if (!$GLOBALS['USE_CACHING_FRAMEWORK']) {
|
||
// Unserializing
|
||
$storeArr = unserialize($storeArrDat);
|
||
} else {
|
||
$storeArr = $storeArrDat;
|
||
}
|
||
// Setting cache:
|
||
$this->substMarkerCache[$storeKey] = $storeArr;
|
||
$GLOBALS['TT']->setTSlogMessage('Cached from DB',0);
|
||
}
|
||
}
|
||
// Substitution/Merging:
|
||
// Merging content types together, resetting
|
||
$valueArr = array_merge($markContentArray,$subpartContentArray,$wrappedSubpartContentArray);
|