}
public static function onArticleDelete( $title ) {
- global $wgUseFileCache, $wgMessageCache;
+ global $wgMessageCache;
# Update existence markers on article/talk tabs...
if( $title->isTalkPage() ) {
$other = $title->getSubjectPage();
$title->purgeSquid();
# File cache
- if( $wgUseFileCache ) {
- $cm = new HTMLFileCache( $title );
- @unlink( $cm->fileCacheName() );
- }
+ HTMLFileCache::clearFileCache( $title );
# Messages
if( $title->getNamespace() == NS_MEDIAWIKI ) {
* Purge caches on page update etc
*/
public static function onArticleEdit( $title, $transclusions = 'transclusions' ) {
- global $wgDeferredUpdateList, $wgUseFileCache;
+ global $wgDeferredUpdateList;
// Invalidate caches of articles which include this page
if( $transclusions !== 'skiptransclusions' )
$title->purgeSquid();
# Clear file cache for this page only
- if( $wgUseFileCache ) {
- $cm = new HTMLFileCache( $title );
- @unlink( $cm->fileCacheName() );
- }
+ HTMLFileCache::clearFileCache( $title );
}
/**#@-*/
* @ingroup Cache
*/
class HTMLFileCache {
- var $mTitle, $mFileCache;
+ var $mTitle, $mFileCache, $mType;
- public function __construct( &$title ) {
+ public function __construct( &$title, $type = 'view' ) {
$this->mTitle = $title;
- $this->mFileCache = $this->fileCacheName();
+ $this->mType = ($type == 'raw' || $type == 'view' ) ? $type : false;
+ $this->fileCacheName(); // init name
}
public function fileCacheName() {
if( !$this->mFileCache ) {
global $wgFileCacheDirectory, $wgRequest;
+ # Store raw pages (like CSS hits) elsewhere
+ $subdir = ($this->mType === 'raw') ? 'raw/' : '';
$key = $this->mTitle->getPrefixedDbkey();
$hash = md5( $key );
# Avoid extension confusion
$key = str_replace( '.', '%2E', urlencode( $key ) );
- # Store raw pages (like CSS hits) elsewhere
- $subdir = $wgRequest->getVal('action') == 'raw' ? 'raw/' : '';
$hash1 = substr( $hash, 0, 1 );
$hash2 = substr( $hash, 0, 2 );
}
public function isFileCached() {
+ if( $this->mType === false ) return false;
return file_exists( $this->fileCacheName() );
}
if( $query == 'title' || $query == 'curid' ) continue;
// Normal page view in query form can have action=view.
// Raw hits for pages also stored, like .css pages for example.
- if( $query == 'action' && ($val == 'view' || $val == 'raw') ) continue;
- if( $query == 'usemsgcache' && $val == 'yes' ) continue;
+ else if( $query == 'action' && ($val == 'view' || $val == 'raw') ) continue;
+ else if( $query == 'usemsgcache' && $val == 'yes' ) continue;
// Below are header setting params
- if( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' )
+ else if( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' )
continue;
+ else
+ return false;
}
// Check for non-standard user language; this covers uselang,
// and extensions for auto-detecting user language.
return $text;
}
+ public static function clearFileCache( $title ) {
+ global $wgUseFileCache;
+ if( !$wgUseFileCache ) return false;
+ $fc = new self( $title, '' );
+ @unlink( $fc->fileCacheName() );
+ $fc = new self( $title, 'raw' );
+ @unlink( $fc->fileCacheName() );
+ return true;
+ }
}
header( 'Cache-Control: '.$mode.', s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage );
if( HTMLFileCache::useFileCache() ) {
- $cache = new HTMLFileCache( $this->mTitle );
+ $cache = new HTMLFileCache( $this->mTitle, 'raw' );
if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
/* Check incoming headers to see if client has this cached */
if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {