* Handles talking to the file cache, putting stuff in and taking it back out.
* Mostly called from Article.php, also from DatabaseFunctions.php for the
* emergency abort/fallback to cache.
* Handles talking to the file cache, putting stuff in and taking it back out.
* Mostly called from Article.php, also from DatabaseFunctions.php for the
* emergency abort/fallback to cache.
- $hash = md5( $key = $this->mTitle->getDbkey() );
- if( $this->mTitle->getNamespace() )
- $key = $wgContLang->getNsText( $this->mTitle->getNamespace() ) . ":" . $key;
+ $key = $this->mTitle->getPrefixedDbkey();
+ $hash = md5( $key );
$hash1 = substr( $hash, 0, 1 );
$hash2 = substr( $hash, 0, 2 );
$this->mFileCache = "{$wgFileCacheDirectory}/{$hash1}/{$hash2}/{$key}.html";
$hash1 = substr( $hash, 0, 1 );
$hash2 = substr( $hash, 0, 2 );
$this->mFileCache = "{$wgFileCacheDirectory}/{$hash1}/{$hash2}/{$key}.html";
function fileCacheTime() {
return wfTimestamp( TS_MW, filemtime( $this->fileCacheName() ) );
}
function fileCacheTime() {
return wfTimestamp( TS_MW, filemtime( $this->fileCacheName() ) );
}
$cachetime = $this->fileCacheTime();
$good = (( $timestamp <= $cachetime ) &&
( $wgCacheEpoch <= $cachetime ));
$cachetime = $this->fileCacheTime();
$good = (( $timestamp <= $cachetime ) &&
( $wgCacheEpoch <= $cachetime ));
wfDebug(" isFileCacheGood() - cachetime $cachetime, touched {$timestamp} epoch {$wgCacheEpoch}, good $good\n");
return $good;
}
wfDebug(" isFileCacheGood() - cachetime $cachetime, touched {$timestamp} epoch {$wgCacheEpoch}, good $good\n");
return $good;
}
/* In handy string packages */
function fetchRawText() {
return file_get_contents( $this->fileCacheName() );
}
/* In handy string packages */
function fetchRawText() {
return file_get_contents( $this->fileCacheName() );
}
/* Working directory to/from output */
function loadFromFileCache() {
global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode;
wfDebug(" loadFromFileCache()\n");
/* Working directory to/from output */
function loadFromFileCache() {
global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode;
wfDebug(" loadFromFileCache()\n");
$filename=$this->fileCacheName();
$wgOut->sendCacheControl();
header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
header( "Content-language: $wgContLanguageCode" );
$filename=$this->fileCacheName();
$wgOut->sendCacheControl();
header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
header( "Content-language: $wgContLanguageCode" );
function checkCacheDirs() {
$filename = $this->fileCacheName();
$mydir2=substr($filename,0,strrpos($filename,'/')); # subdirectory level 2
$mydir1=substr($mydir2,0,strrpos($mydir2,'/')); # subdirectory level 1
function checkCacheDirs() {
$filename = $this->fileCacheName();
$mydir2=substr($filename,0,strrpos($filename,'/')); # subdirectory level 2
$mydir1=substr($mydir2,0,strrpos($mydir2,'/')); # subdirectory level 1
if(!file_exists($mydir1)) { mkdir($mydir1,0775); } # create if necessary
if(!file_exists($mydir2)) { mkdir($mydir2,0775); }
}
if(!file_exists($mydir1)) { mkdir($mydir1,0775); } # create if necessary
if(!file_exists($mydir2)) { mkdir($mydir2,0775); }
}
function saveToFileCache( $origtext ) {
$text = $origtext;
if(strcmp($text,'') == 0) return '';
function saveToFileCache( $origtext ) {
$text = $origtext;
if(strcmp($text,'') == 0) return '';