mediawiki-extensions-Echo/includes/cache/TitleLocalCache.php
bsitu 55fb42b681 [4] Add revision local cache holder object
Change-Id: I85f68b3ca269c711a8a177e013bd8eba38833444
2014-08-19 10:28:38 -07:00

50 lines
951 B
PHP

<?php
/**
* Cache class that maps article id to Title object
*/
class EchoTitleLocalCache extends EchoLocalCache {
/**
* @var EchoTitleLocalCache
*/
private static $instance;
/**
* The current wiki id
* @var string|null
*/
private static $wiki;
/**
* Create a TitleLocalCache object
* @return TitleLocalCache
*/
public static function create() {
// A job queue may run against multiple wikis,
// initialize a new one for the current wiki
if ( wfWikiId() != self::$wiki ) {
self::$instance = null;
self::$wiki = wfWikiId();
}
if ( !self::$instance ) {
self::$instance = new EchoTitleLocalCache();
}
return self::$instance;
}
/**
* {@inheritDoc}
*/
protected function resolve() {
if ( $this->lookups ) {
$titles = Title::newFromIDs( $this->lookups );
foreach ( $titles as $title ) {
$this->targets->set( $title->getArticleId(), $title );
}
$this->lookups = array();
}
}
}