From ceeba5efe65eadc4c303f4e888b98f9da97f822d Mon Sep 17 00:00:00 2001 From: TChin Date: Fri, 1 Oct 2021 15:54:27 -0400 Subject: [PATCH] Replace deprecated Title::newFromIDs Bug: T291288 Change-Id: I259d3f8d4c4fc7cd8ce008f3e63d1208c2b002b7 --- extension.json | 5 +++- .../api/ApiEchoUnreadNotificationPages.php | 26 +++++++++++++++++-- includes/cache/TitleLocalCache.php | 13 +++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/extension.json b/extension.json index f69821c73..0c8ca1166 100644 --- a/extension.json +++ b/extension.json @@ -22,7 +22,10 @@ "class": "ApiEchoNotifications", "services": [ "MainConfig" ] }, - "unreadnotificationpages": "ApiEchoUnreadNotificationPages" + "unreadnotificationpages": { + "class": "ApiEchoUnreadNotificationPages", + "services": [ "PageStore", "TitleFactory" ] + } }, "APIModules": { "echomarkread": "ApiEchoMarkRead", diff --git a/includes/api/ApiEchoUnreadNotificationPages.php b/includes/api/ApiEchoUnreadNotificationPages.php index 0d39b18ff..9d2e3ff9f 100644 --- a/includes/api/ApiEchoUnreadNotificationPages.php +++ b/includes/api/ApiEchoUnreadNotificationPages.php @@ -1,6 +1,8 @@ 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(); diff --git a/includes/cache/TitleLocalCache.php b/includes/cache/TitleLocalCache.php index b756b0f79..5a995f979 100644 --- a/includes/cache/TitleLocalCache.php +++ b/includes/cache/TitleLocalCache.php @@ -1,5 +1,8 @@ getPageStore() + ->newSelectQueryBuilder() + ->wherePageIds( $lookups ) + ->caller( __METHOD__ ) + ->fetchPageRecords(); + + /** @var PageRecord $title */ foreach ( $titles as $title ) { + $title = MediaWikiServices::getInstance()->getTitleFactory()->castFromPageIdentity( $title ); yield $title->getArticleID() => $title; } }