Bug #20737 » 0011505_v6.patch
t3lib/config_default.php (Arbeitskopie) | ||
---|---|---|
'cache_hash' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_hash'
|
||
'cacheTable' => 'cachingframework_cache_hash'
|
||
)
|
||
),
|
||
'cache_pages' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_pages'
|
||
'cacheTable' => 'cachingframework_cache_pages'
|
||
)
|
||
),
|
||
'cache_pagesection' => array(
|
||
'backend' => 't3lib_cache_backend_DbBackend',
|
||
'options' => array(
|
||
'cacheTable' => 'cache_pagesection'
|
||
'cacheTable' => 'cachingframework_cache_pagesection'
|
||
)
|
||
)
|
||
/*
|
||
... | ... | |
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 by default for the core caches cache_pages, cache_pagesection and cache_hash.
|
||
),
|
||
'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.)
|
t3lib/stddb/tables.sql (Arbeitskopie) | ||
---|---|---|
#
|
||
CREATE TABLE cache_hash (
|
||
id int(11) unsigned NOT NULL auto_increment,
|
||
hash varchar(32) DEFAULT '' NOT NULL,
|
||
content mediumtext,
|
||
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||
ident varchar(32) DEFAULT '' NOT NULL,
|
||
PRIMARY KEY (id)
|
||
KEY hash (hash)
|
||
) ENGINE=InnoDB;
|
||
#
|
||
# Table structure for table 'cachingframework_cache_hash'
|
||
#
|
||
CREATE TABLE cachingframework_cache_hash (
|
||
id int(11) unsigned NOT NULL auto_increment,
|
||
identifier varchar(250) DEFAULT '' NOT NULL,
|
||
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||
content mediumtext,
|
t3lib/class.t3lib_tstemplate.php (Arbeitskopie) | ||
---|---|---|
* @see start(), tslib_fe::getFromCache()
|
||
*/
|
||
function getCurrentPageData() {
|
||
$currentPageData = false;
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
$cacheEntry = $pageSectionCache->get(
|
||
intval($GLOBALS['TSFE']->id) . '_' . t3lib_div::md5int($GLOBALS['TSFE']->MP)
|
||
$currentPageData = t3lib_cache::getFromPageSectionCache(
|
||
$GLOBALS['TSFE']->id,
|
||
t3lib_div::md5int($GLOBALS['TSFE']->MP)
|
||
);
|
||
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);
|
||
$pageSectionCache->set(
|
||
intval($GLOBALS['TSFE']->id) . '_' . $mpvarHash,
|
||
serialize($cc),
|
||
array(
|
||
'pageId_' . intval($GLOBALS['TSFE']->id),
|
||
'mpvarHash_' . $mpvarHash
|
||
)
|
||
t3lib_cache::setToPageSectionCache(
|
||
$GLOBALS['TSFE']->id,
|
||
t3lib_div::md5int($GLOBALS['TSFE']->MP),
|
||
serialize($cc)
|
||
);
|
||
}
|
||
// 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
|
||
);
|
||
t3lib_cache::setToHashCache($hash, $data, $ident);
|
||
}
|
||
/**
|
||
... | ... | |
* @param string The hash-string which was used to store the data value
|
||
* @return string
|
||
*/
|
||
public static function getHash($hash) {
|
||
$hashContent = null;
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
if ($cacheEntry) {
|
||
$hashContent = $cacheEntry;
|
||
}
|
||
return $hashContent;
|
||
public static function getHash($hash, $expTime = 0) {
|
||
return t3lib_cache::getFromHashCache($hash, $expTime);
|
||
}
|
||
t3lib/class.t3lib_cache.php (Arbeitskopie) | ||
---|---|---|
* @subpackage t3lib
|
||
*/
|
||
class t3lib_cache {
|
||
/**
|
||
* @var boolean
|
||
*/
|
||
protected static $isCachingFrameworkEnabled;
|
||
/**
|
||
* @var boolean
|
||
*/
|
||
protected static $isCachingFrameworkInitialized;
|
||
/**
|
||
* Initializes the caching framework by loading the cache manager and factory
|
||
* into the global context.
|
||
*
|
||
* @return void
|
||
*/
|
||
public static function initializeCachingFramework() {
|
||
$GLOBALS['typo3CacheManager'] = t3lib_div::makeInstance('t3lib_cache_Manager');
|
||
$GLOBALS['typo3CacheFactory'] = t3lib_div::makeInstance('t3lib_cache_Factory');
|
||
$GLOBALS['typo3CacheFactory']->setCacheManager($GLOBALS['typo3CacheManager']);
|
||
self::$isCachingFrameworkInitialized = true;
|
||
}
|
||
/**
|
||
* initializes the cache_pages cache
|
||
*
|
||
* @return void
|
||
... | ... | |
// do nothing, a cache_hash cache already exists
|
||
}
|
||
}
|
||
/**
|
||
* Determines whether the caching framework is enabled for core disposal.
|
||
*
|
||
* @return boolean
|
||
*/
|
||
public function isCachingFrameworkEnabled() {
|
||
if (!isset(self::$isCachingFrameworkEnabled)) {
|
||
self::$isCachingFrameworkEnabled = (bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['useCachingFramework'];
|
||
}
|
||
return self::$isCachingFrameworkEnabled;
|
||
}
|
||
/**
|
||
* Determines whether the caching framework is initialized.
|
||
* The caching framework could be disabled for the core but used by an extension.
|
||
*
|
||
* @return boolean
|
||
*/
|
||
public function isCachingFrameworkInitialized() {
|
||
return (bool)self::$isCachingFrameworkInitialized;
|
||
}
|
||
/**
|
||
* Flushes cache_pages or cachinframework_cache_pages.
|
||
*
|
||
* @param array $pageIds: (optional) Ids of pages to be deleted
|
||
* @return void
|
||
*/
|
||
public static function flushPageCache(array $pageIds = NULL) {
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
|
||
if (!is_null($pageIds)) {
|
||
foreach ($pageIds as $pageId) {
|
||
$pageCache->flushByTag('pageId_' . $pageId);
|
||
}
|
||
} else {
|
||
$pageCache->flush();
|
||
}
|
||
} elseif (!is_null($pageIds)) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN (' . implode(',', $pageIds) . ')');
|
||
} else {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', '');
|
||
}
|
||
}
|
||
/**
|
||
* Gets data from cache_pagesection or cachingframework_cache_pagesection.
|
||
*
|
||
* @param integer $pageId: The Id of a page
|
||
* @param integer $mpHash: The mointpoint hash
|
||
* @return array
|
||
*/
|
||
public static function getFromPageSectionCache($pageId, $mpHash) {
|
||
$data = false;
|
||
$pageId = intval($pageId);
|
||
$mpHash = intval($mpHash);
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
$cacheEntry = $pageSectionCache->get($pageId . '_' . $mpHash);
|
||
if ($cacheEntry) {
|
||
$data = unserialize($cacheEntry);
|
||
}
|
||
} else {
|
||
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
|
||
'content',
|
||
'cache_pagesection',
|
||
'page_id=' . $pageId . ' AND mpvar_hash=' . $mpHash
|
||
);
|
||
if ($rows) {
|
||
$data = unserialize($rows[0]['content']);
|
||
}
|
||
}
|
||
return $data;
|
||
}
|
||
/**
|
||
* Sets data to cache_pagesection or cachingframework_cache_pagesection.
|
||
*
|
||
* @param integer $pageId: The Id of a page
|
||
* @param integer $mpHash: The mointpoint hash
|
||
* @param string $data: Data to be stored
|
||
* @return void
|
||
*/
|
||
public static function setToPageSectionCache($pageId, $mpHash, $data) {
|
||
$pageId = intval($pageId);
|
||
$mpHash = intval($mpHash);
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
/* @var $pageSectionCache t3lib_cache_AbstractCache */
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
$pageSectionCache->set(
|
||
$pageId . '_' . $mpHash,
|
||
$data,
|
||
array(
|
||
'pageId_' . $pageId,
|
||
'mpvarHash_' . $mpHash
|
||
)
|
||
);
|
||
} else {
|
||
$dbFields = array(
|
||
'content' => $data,
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . $pageId . ' AND mpvar_hash=' . $mpHash, $dbFields);
|
||
if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
|
||
$dbFields['page_id'] = $pageId;
|
||
$dbFields['mpvar_hash'] = $mpHash;
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Flushes cache_pagesection or cachingframework_cache_pagesection.
|
||
*
|
||
* @param array $pageIds: (optional) Ids of pages to be deleted
|
||
* @return void
|
||
*/
|
||
public static function flushPageSectionCache(array $pageIds = NULL) {
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
$pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
|
||
if (!is_null($pageIds)) {
|
||
foreach ($pageIds as $pageId) {
|
||
$pageSectionCache->flushByTag('pageId_' . $pageId);
|
||
}
|
||
} else {
|
||
$pageSectionCache->flush();
|
||
}
|
||
} elseif (!is_null($pageIds)) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', 'page_id IN (' . implode(',',$pageIds) . ')');
|
||
} else {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', '');
|
||
}
|
||
}
|
||
/**
|
||
* Gets data from cache_hash or cachingframework_cache_hash
|
||
*
|
||
* @param string $hash: The hash-string which was used to store the data value
|
||
* @param integer $expTime: Optional expiration time
|
||
* @return string The cached data
|
||
*/
|
||
public static function getFromHashCache($hash, $expTime = 0) {
|
||
$data = null;
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
if ($cacheEntry) {
|
||
$data = $cacheEntry;
|
||
}
|
||
} else {
|
||
$expTime = intval($expTime);
|
||
if ($expTime) {
|
||
$whereAdd = ' AND tstamp > '.($GLOBALS['ACCESS_TIME'] - $expTime);
|
||
}
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'content',
|
||
'cache_hash',
|
||
'hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash') . $whereAdd
|
||
);
|
||
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
$data = (is_array($row) ? $row['content'] : null);
|
||
}
|
||
return $data;
|
||
}
|
||
/**
|
||
* Stores data in cache_hash or cachingframework_cache_hash.
|
||
*
|
||
* @param string $hash: 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)
|
||
* @param string $data: The data string. If you want to store an array, then just serialize it first.
|
||
* @param string $ident: Just a textual identification in order to inform about the content!
|
||
* @param integer $lifetime: Optional life time for a cache entry
|
||
* @return void
|
||
*/
|
||
public static function setToHashCache($hash, $data, $ident, $lifetime = 0) {
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set(
|
||
$hash,
|
||
$data,
|
||
array('ident_' . $ident),
|
||
$lifetime
|
||
);
|
||
} else {
|
||
$insertFields = array(
|
||
'hash' => $hash,
|
||
'content' => $data,
|
||
'ident' => $ident,
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
);
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash'));
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_hash', $insertFields);
|
||
}
|
||
}
|
||
/**
|
||
* Flushes cache_hash or cachingframework_cache_hash.
|
||
*
|
||
* @return void
|
||
*/
|
||
public static function flushHashCache() {
|
||
if (self::isCachingFrameworkEnabled()) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->flush();
|
||
} else {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_hash','');
|
||
}
|
||
}
|
||
}
|
||
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) {
|
||
$hashContent = null;
|
||
$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
|
||
$cacheEntry = $contentHashCache->get($hash);
|
||
if ($cacheEntry) {
|
||
$hashContent = $cacheEntry;
|
||
}
|
||
return $hashContent;
|
||
public static function getHash($hash, $expTime = 0) {
|
||
return t3lib_cache::getFromHashCache($hash, $expTime);
|
||
}
|
||
/**
|
||
... | ... | |
* @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
|
||
);
|
||
t3lib_cache::setToHashCache($hash, $data, $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);
|
||
$cacheContent = t3lib_pageSelect::getHash($identifier, 0);
|
||
$array = unserialize($cacheContent);
|
||
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);
|
||
t3lib_pageSelect::storeHash($identifier, serialize($array), 'ident_xml2array');
|
||
}
|
||
// store content in first level cache
|
||
$firstLevelCache[$identifier] = $array;
|
t3lib/class.t3lib_tsfebeuserauth.php (Arbeitskopie) | ||
---|---|---|
* @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);
|
||
return count($pageCacheEntries);
|
||
if (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
$pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
|
||
$pageCacheEntries = $pageCache->getByTag('pageId_' . (int) $pageId);
|
||
$count = count($pageCacheEntries);
|
||
} else {
|
||
$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'cache_pages', 'page_id='.intval($pageId));
|
||
}
|
||
return $count;
|
||
}
|
||
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'
|
||
);
|
||
$pageIds = $GLOBALS['TYPO3_DB']->cleanIntArray($list_cache);
|
||
foreach ($pageIds as $pageId) {
|
||
$pageCache->flushByTag('pageId_' . $pageId);
|
||
$pageSectionCache->flushByTag('pageId_' . $pageId);
|
||
}
|
||
t3lib_cache::flushPageCache($pageIds);
|
||
t3lib_cache::flushPageSectionCache($pageIds);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
case 'all':
|
||
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
|
||
// clear all caches that use the t3lib_cache framework
|
||
$GLOBALS['typo3CacheManager']->flushCaches();
|
||
// Clear all caching framework caches if it is initialized:
|
||
// (it could be disabled by initialized by an extension)
|
||
if (t3lib_cache::isCachingFrameworkInitialized()) {
|
||
$GLOBALS['typo3CacheManager']->flushCaches();
|
||
}
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', '');
|
||
// Clear caches if the caching framework is disabled for core caches:
|
||
if (!t3lib_cache::isCachingFrameworkEnabled()) {
|
||
t3lib_cache::flushPageSectionCache();
|
||
$this->internal_clearPageCache();
|
||
t3lib_cache::flushHashCache();
|
||
}
|
||
}
|
||
// 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);
|
||
}
|
||
$pageIds = $GLOBALS['TYPO3_DB']->cleanIntArray($list_cache);
|
||
t3lib_cache::flushPageCache($pageIds);
|
||
t3lib_cache::flushPageSectionCache($pageIds);
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
*/
|
||
function internal_clearPageCache() {
|
||
if (t3lib_extMgm::isLoaded('cms')) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_pages')->flush();
|
||
$externalFiles = $GLOBALS['TYPO3_CONF_VARS']['FE']['pageCacheToExternalFiles'];
|
||
if (!t3lib_cache::isCachingFrameworkEnabled() && $externalFiles) {
|
||
$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);
|
||
}
|
||
}
|
||
t3lib_cache::flushPageCache();
|
||
}
|
||
}
|
||
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 (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
t3lib_cache::initializeCachingFramework();
|
||
t3lib_cache::initPageCache();
|
||
t3lib_cache::initPageSectionCache();
|
||
t3lib_cache::initContentHashCache();
|
||
unset($cacheFactoryClass);
|
||
t3lib_cache::initPageCache();
|
||
t3lib_cache::initPageSectionCache();
|
||
t3lib_cache::initContentHashCache();
|
||
}
|
||
// *************************
|
||
// CLI dispatch processing
|
||
// *************************
|
typo3/sysext/cms/ext_tables.sql (Arbeitskopie) | ||
---|---|---|
#
|
||
CREATE TABLE cache_pages (
|
||
id int(11) unsigned NOT NULL auto_increment,
|
||
hash varchar(32) DEFAULT '' NOT NULL,
|
||
page_id int(11) unsigned DEFAULT '0' NOT NULL,
|
||
reg1 int(11) unsigned DEFAULT '0' NOT NULL,
|
||
HTML mediumtext,
|
||
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 mediumtext,
|
||
KEY page_id (page_id),
|
||
KEY sel (hash,page_id),
|
||
PRIMARY KEY (id)
|
||
) ENGINE=InnoDB;
|
||
#
|
||
# Table structure for table 'cache_pagesection'
|
||
#
|
||
CREATE TABLE cache_pagesection (
|
||
page_id int(11) unsigned DEFAULT '0' NOT NULL,
|
||
mpvar_hash int(11) unsigned DEFAULT '0' NOT NULL,
|
||
content text,
|
||
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
|
||
PRIMARY KEY (page_id,mpvar_hash)
|
||
) ENGINE=InnoDB;
|
||
#
|
||
# Table structure for table 'cachingframework_cache_pages'
|
||
#
|
||
CREATE TABLE cachingframework_cache_pages (
|
||
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;
|
||
#
|
||
# Table structure for table 'cache_pagesection'
|
||
# Table structure for table 'cachingframework_cache_pagesection'
|
||
#
|
||
CREATE TABLE cache_pagesection (
|
||
CREATE TABLE cachingframework_cache_pagesection (
|
||
id int(11) unsigned NOT NULL auto_increment,
|
||
identifier varchar(250) DEFAULT '' NOT NULL,
|
||
crdate int(11) unsigned DEFAULT '0' NOT NULL,
|
||
content mediumtext,
|
||
tags mediumtext,
|
||
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) | ||
---|---|---|
********************************************/
|
||
/**
|
||
* Initializes the caching system.
|
||
* Initializes the caching framework.
|
||
*
|
||
* @return void
|
||
*/
|
||
protected function initCaches() {
|
||
$GLOBALS['TT']->push('Initializing the Caching System','');
|
||
if (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
$GLOBALS['TT']->push('Initializing the Caching System', '');
|
||
$GLOBALS['typo3CacheManager'] = t3lib_div::makeInstance('t3lib_cache_Manager');
|
||
$GLOBALS['typo3CacheFactory'] = t3lib_div::makeInstance('t3lib_cache_Factory');
|
||
$GLOBALS['typo3CacheFactory']->setCacheManager($GLOBALS['typo3CacheManager']);
|
||
t3lib_cache::initializeCachingFramework();
|
||
try {
|
||
$this->pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
} catch(t3lib_cache_exception_NoSuchCache $e) {
|
||
t3lib_cache::initPageCache();
|
||
try {
|
||
$this->pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
} catch(t3lib_cache_exception_NoSuchCache $e) {
|
||
t3lib_cache::initPageCache();
|
||
$this->pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
}
|
||
$this->pageCache = $GLOBALS['typo3CacheManager']->getCache(
|
||
'cache_pages'
|
||
);
|
||
}
|
||
t3lib_cache::initPageSectionCache();
|
||
t3lib_cache::initContentHashCache();
|
||
t3lib_cache::initPageSectionCache();
|
||
t3lib_cache::initContentHashCache();
|
||
$GLOBALS['TT']->pull();
|
||
$GLOBALS['TT']->pull();
|
||
}
|
||
}
|
||
/**
|
||
... | ... | |
if (is_array($row)) {
|
||
// Release this lock
|
||
$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 = (t3lib_cache::isCachingFrameworkEnabled() ? $row['content'] : $row['HTML']); // 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 (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
$GLOBALS['TT']->push('Cache Query', '');
|
||
$row = $this->pageCache->get($this->newHash);
|
||
$GLOBALS['TT']->pull();
|
||
} else {
|
||
$GLOBALS['TT']->push('Cache Query','');
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'S.*',
|
||
'cache_pages S,pages P',
|
||
'S.hash='.$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);
|
||
}
|
||
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 (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
$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->pageCacheTags[] = 'pageId_' . $cacheData['page_id'];
|
||
$this->cacheExpires = $expirationTstamp;
|
||
if ($this->page_cache_reg1) {
|
||
$reg1 = intval($this->page_cache_reg1);
|
||
$this->pageCacheTags[] = 'pageId_' . $cacheData['page_id'];
|
||
$cacheData['reg1'] = $reg1;
|
||
$this->pageCacheTags[] = 'reg1_' . $reg1;
|
||
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']
|
||
);
|
||
} else {
|
||
$this->clearPageCacheContent();
|
||
$insertFields = 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 ($this->page_cache_reg1) {
|
||
$insertFields['reg1'] = intval($this->page_cache_reg1);
|
||
}
|
||
$this->pageCachePostProcess($insertFields,'set');
|
||
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pages', $insertFields);
|
||
}
|
||
$this->pageCache->set(
|
||
$cacheData['hash'],
|
||
$cacheData,
|
||
$this->pageCacheTags,
|
||
$cacheData['expires'] - $GLOBALS['EXEC_TIME']
|
||
);
|
||
}
|
||
/**
|
||
... | ... | |
* @return void
|
||
*/
|
||
function clearPageCacheContent() {
|
||
$this->pageCache->remove($this->newHash);
|
||
if (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
$this->pageCache->remove($this->newHash);
|
||
} else {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->newHash, 'cache_pages'));
|
||
}
|
||
}
|
||
/**
|
||
* 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);
|
||
foreach ($pageIds as $pageId) {
|
||
$this->pageCache->flushByTag('pageId_' . (int) $pageId);
|
||
if (t3lib_cache::isCachingFrameworkEnabled()) {
|
||
$pageIds = t3lib_div::trimExplode(',', $pidList);
|
||
foreach ($pageIds as $pageId) {
|
||
$this->pageCache->flushByTag('pageId_' . (int) $pageId);
|
||
}
|
||
} else {
|
||
$GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id IN ('.$GLOBALS['TYPO3_DB']->cleanIntList($pidList).')');
|
||
}
|
||
}
|
||
typo3/sysext/cms/tslib/class.tslib_fetce.php (Arbeitskopie) | ||
---|---|---|
* @see tslib_fe::set_no_cache()
|
||
*/
|
||
function clear_cacheCmd($cacheCmd) {
|
||
$cacheCmd = intval($cacheCmd);
|
||
if (t3lib_div::testInt($cacheCmd)) {
|
||
t3lib_cache::flushPageCache(array($cacheCmd));
|
||
if ($cacheCmd) {
|
||
$GLOBALS['typo3CacheManager']->getCache('cache_pages')->flushByTag(
|
||
'pageId_' . $cacheCmd
|
||
);
|
||
if ($cacheCmd == intval($GLOBALS['TSFE']->id)) {
|
||
// Setting no_cache true if the cleared-cache page is the current page!
|
||
$GLOBALS['TSFE']->set_no_cache();
|