mediawiki-extensions-Echo/includes/cache/TitleLocalCache.php
TChin ceeba5efe6 Replace deprecated Title::newFromIDs
Bug: T291288
Change-Id: I259d3f8d4c4fc7cd8ce008f3e63d1208c2b002b7
2021-10-01 16:22:36 -04:00

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;
}
}
}
}