mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-21 04:03:40 +00:00
ceeba5efe6
Bug: T291288 Change-Id: I259d3f8d4c4fc7cd8ce008f3e63d1208c2b002b7
48 lines
940 B
PHP
48 lines
940 B
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\Page\PageRecord;
|
|
|
|
/**
|
|
* Cache class that maps article id to Title object
|
|
*/
|
|
class EchoTitleLocalCache extends EchoLocalCache {
|
|
|
|
/**
|
|
* @var EchoTitleLocalCache
|
|
*/
|
|
private static $instance;
|
|
|
|
/**
|
|
* @return EchoTitleLocalCache
|
|
*/
|
|
public static function create() {
|
|
if ( !self::$instance ) {
|
|
self::$instance = new EchoTitleLocalCache();
|
|
}
|
|
|
|
return self::$instance;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
protected function resolve( array $lookups ) {
|
|
if ( $lookups ) {
|
|
$titles = MediaWikiServices::getInstance()
|
|
->getPageStore()
|
|
->newSelectQueryBuilder()
|
|
->wherePageIds( $lookups )
|
|
->caller( __METHOD__ )
|
|
->fetchPageRecords();
|
|
|
|
/** @var PageRecord $title */
|
|
foreach ( $titles as $title ) {
|
|
$title = MediaWikiServices::getInstance()->getTitleFactory()->castFromPageIdentity( $title );
|
|
yield $title->getArticleID() => $title;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|