wfProfileIn( 'main-try-filecache' );
if ( HTMLFileCache::useFileCache( $this->context ) ) {
// Try low-level file cache hit
- $cache = HTMLFileCache::newFromTitle( $title, $action );
+ $cache = new HTMLFileCache( $title, $action );
if ( $cache->isCacheGood( /* Assume up to date */ ) ) {
// Check incoming headers to see if client has this cached
$timestamp = $cache->cacheTimestamp();
# Fill in the file cache if not set already
$useFileCache = $config->get( 'UseFileCache' );
if ( $useFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
- $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' );
+ $cache = new HTMLFileCache( $this->getTitle(), 'history' );
if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
ob_start( array( &$cache, 'saveToFileCache' ) );
}
* @param string $action
* @throws MWException
* @return HTMLFileCache
+ *
+ * @deprecated Since 1.24, instantiate this class directly
*/
public static function newFromTitle( $title, $action ) {
- $cache = new self();
+ return new self( $title, $action );
+ }
+ /**
+ * @param Title|string $title Title object or prefixed DB key string
+ * @param string $action
+ * @throws MWException
+ */
+ public function __construct( $title, $action ) {
$allowedTypes = self::cacheablePageActions();
if ( !in_array( $action, $allowedTypes ) ) {
- throw new MWException( "Invalid filecache type given." );
+ throw new MWException( 'Invalid file cache type given.' );
}
- $cache->mKey = ( $title instanceof Title )
+ $this->mKey = ( $title instanceof Title )
? $title->getPrefixedDBkey()
: (string)$title;
- $cache->mType = (string)$action;
- $cache->mExt = 'html';
-
- return $cache;
+ $this->mType = (string)$action;
+ $this->mExt = 'html';
}
/**
}
foreach ( self::cacheablePageActions() as $type ) {
- $fc = self::newFromTitle( $title, $type );
+ $fc = new self( $title, $type );
$fc->clearCache();
}
}
}
- $cache = HTMLFileCache::newFromTitle( $t, 'view' );
+ $cache = new HTMLFileCache( $t, 'view' );
if ( $cache->isCached() ) {
return $cache->fetchText();
} else {
$called = true;
if ( $this->isFileCacheable() ) {
- $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'view' );
+ $cache = new HTMLFileCache( $this->getTitle(), 'view' );
if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
wfDebug( "Article::tryFileCache(): about to load file\n" );
$cache->loadFromFileCache( $this->getContext() );