mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
55fb42b681
Change-Id: I85f68b3ca269c711a8a177e013bd8eba38833444
50 lines
951 B
PHP
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();
|
|
}
|
|
}
|
|
|
|
}
|