mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-14 19:28:31 +00:00
3609edf153
Change-Id: I8ead3ee485528f08f71c21cf401880bf369dbeac
50 lines
972 B
PHP
50 lines
972 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Cache;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\Page\PageRecord;
|
|
|
|
/**
|
|
* Cache class that maps article id to Title object
|
|
*/
|
|
class TitleLocalCache extends LocalCache {
|
|
|
|
/**
|
|
* @var TitleLocalCache
|
|
*/
|
|
private static $instance;
|
|
|
|
/**
|
|
* @return TitleLocalCache
|
|
*/
|
|
public static function create() {
|
|
if ( !self::$instance ) {
|
|
self::$instance = new TitleLocalCache();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|