mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
Merge "Replace deprecated Title::newFromIDs"
This commit is contained in:
commit
30cd2a226f
|
@ -22,7 +22,10 @@
|
|||
"class": "ApiEchoNotifications",
|
||||
"services": [ "MainConfig" ]
|
||||
},
|
||||
"unreadnotificationpages": "ApiEchoUnreadNotificationPages"
|
||||
"unreadnotificationpages": {
|
||||
"class": "ApiEchoUnreadNotificationPages",
|
||||
"services": [ "PageStore", "TitleFactory" ]
|
||||
}
|
||||
},
|
||||
"APIModules": {
|
||||
"echomarkread": "ApiEchoMarkRead",
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Page\PageRecord;
|
||||
use MediaWiki\Page\PageStore;
|
||||
|
||||
class ApiEchoUnreadNotificationPages extends ApiQueryBase {
|
||||
use ApiCrossWiki;
|
||||
|
@ -10,12 +12,26 @@ class ApiEchoUnreadNotificationPages extends ApiQueryBase {
|
|||
*/
|
||||
protected $crossWikiSummary = false;
|
||||
|
||||
/**
|
||||
* @var PageStore
|
||||
*/
|
||||
private $pageStore;
|
||||
|
||||
/**
|
||||
* @var TitleFactory
|
||||
*/
|
||||
private $titleFactory;
|
||||
|
||||
/**
|
||||
* @param ApiQuery $query
|
||||
* @param string $moduleName
|
||||
* @param PageStore $pageStore
|
||||
* @param TitleFactory $titleFactory
|
||||
*/
|
||||
public function __construct( $query, $moduleName ) {
|
||||
public function __construct( $query, $moduleName, PageStore $pageStore, TitleFactory $titleFactory ) {
|
||||
parent::__construct( $query, $moduleName, 'unp' );
|
||||
$this->pageStore = $pageStore;
|
||||
$this->titleFactory = $titleFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,10 +112,16 @@ class ApiEchoUnreadNotificationPages extends ApiQueryBase {
|
|||
}
|
||||
}
|
||||
|
||||
$titles = Title::newFromIDs( array_keys( $pageCounts ) );
|
||||
$titles = $this->pageStore
|
||||
->newSelectQueryBuilder()
|
||||
->wherePageIds( array_keys( $pageCounts ) )
|
||||
->caller( __METHOD__ )
|
||||
->fetchPageRecords();
|
||||
|
||||
$groupCounts = [];
|
||||
/** @var PageRecord $title */
|
||||
foreach ( $titles as $title ) {
|
||||
$title = $this->titleFactory->castFromPageIdentity( $title );
|
||||
if ( $groupPages ) {
|
||||
// If $title is a talk page, add its count to its subject page's count
|
||||
$pageName = $title->getSubjectPage()->getPrefixedText();
|
||||
|
|
13
includes/cache/TitleLocalCache.php
vendored
13
includes/cache/TitleLocalCache.php
vendored
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\PageRecord;
|
||||
|
||||
/**
|
||||
* Cache class that maps article id to Title object
|
||||
*/
|
||||
|
@ -26,8 +29,16 @@ class EchoTitleLocalCache extends EchoLocalCache {
|
|||
*/
|
||||
protected function resolve( array $lookups ) {
|
||||
if ( $lookups ) {
|
||||
$titles = Title::newFromIDs( $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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue