Page MenuHomePhabricator

Replace Title::newFromIDs and TitleFactory::newFromIDs with PageQueryBuilder
Open, In Progress, Needs TriagePublic

Description

Title::newFromIDs does a DB lookup to batch-fetch Title objects given a list of page IDs. It bypasses LinkCache completely, neither benefits from it, nor populates it.

newFromIDs method in both Title and TitleFactory should be deprecated. The replacement is:

MediaWikiServices::getInstance()
  ->getPageStore()
  ->newSelectQueryBuilder()
  ->wherePageIds( $pageIDs )
  ->caller( __METHOD__ )
  ->fetchPageRecords();

Instances

Title::newFromIDs

  • core
  • extensions / Echo
  • extensions / CirrusSearch
  • extensions / FlaggedRevs
  • extensions / GettingStarted
  • extensions / WikibaseMediaInfo

TitleFactory::newFromIDs

  • core
  • extensions / GrowthExperiments
  • extensions / Wikibase

Event Timeline

Change 725362 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/Echo@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725362

Change 725365 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/CirrusSearch@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725365

Change 725366 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/GettingStarted@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725366

Change 725362 merged by jenkins-bot:

[mediawiki/extensions/Echo@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725362

Change 725969 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/FlaggedRevs@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725969

Change 725361 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/WikibaseMediaInfo@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725361

Change 725366 merged by jenkins-bot:

[mediawiki/extensions/GettingStarted@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725366

Change 725969 merged by jenkins-bot:

[mediawiki/extensions/FlaggedRevs@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725969

tchin changed the task status from Open to In Progress.Oct 6 2021, 5:14 PM
tchin updated the task description. (Show Details)

Change 725365 merged by jenkins-bot:

[mediawiki/extensions/CirrusSearch@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725365

Change 725361 merged by jenkins-bot:

[mediawiki/extensions/WikibaseMediaInfo@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/725361

Change 728575 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/Wikibase@master] Replace deprecated TitleFactory::newFromIDs

https://gerrit.wikimedia.org/r/728575

Change 727364 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/extensions/GrowthExperiments@master] Replace deprecated TitleFactory::newFromIDs

https://gerrit.wikimedia.org/r/727364

It bypasses LinkCache completely, neither benefits from it, nor populates it.

Does the replacement benefit from LinkCache? As far as I can tell, it adds queried objects to the cache (i.e. populates it), but still includes page IDs that are already cached in the query.

Also, is it intentional that PageStore::newSelectQueryBuilder() indicates two different return types?

	 * @return PageSelectQueryBuilder
	 */
	public function newSelectQueryBuilder( $dbOrFlags = self::READ_NORMAL ): SelectQueryBuilder {

To me it seems strange to call wherePageIds() and fetchPageRecords() on an object that’s not actually guaranteed (at runtime) to be anything more than a general SelectQueryBuilder.

Does the replacement benefit from LinkCache?

Not yet, but neither does Title::newFromIDs. Eventually we would like to use LinkBatch inside re PageSelectQueryBuilder, but for that we'd want to clean up LinkBach a bit first.

Also, is it intentional that PageStore::newSelectQueryBuilder() indicates two different return types?

No, this is a bug. Should be PageSelectQueryBuilder.

Change 731341 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] Fix return type of PageStore::newSelectQueryBuilder()

https://gerrit.wikimedia.org/r/731341

Change 731341 merged by jenkins-bot:

[mediawiki/core@master] Fix return type of PageStore::newSelectQueryBuilder()

https://gerrit.wikimedia.org/r/731341

Change 727364 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Replace deprecated TitleFactory::newFromIDs

https://gerrit.wikimedia.org/r/727364

Change 728575 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace deprecated TitleFactory::newFromIDs

https://gerrit.wikimedia.org/r/728575

Change 739015 had a related patch set uploaded (by TChin; author: TChin):

[mediawiki/core@master] Hard deprecate TitleFactory::newFromIDs and Title::newFromIDs

https://gerrit.wikimedia.org/r/739015

Change 739015 merged by jenkins-bot:

[mediawiki/core@master] Hard deprecate TitleFactory::newFromIDs and Title::newFromIDs

https://gerrit.wikimedia.org/r/739015

Change 745533 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/extensions/IndexFunction@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/745533

It is a bit confusing that the replacement is PageStore::newSelectQueryBuilder which is marked @unstable

Change 745533 merged by Umherirrender:

[mediawiki/extensions/IndexFunction@master] Replace deprecated Title::newFromIDs

https://gerrit.wikimedia.org/r/745533