Page MenuHomePhabricator

Make ApiQueryBase::addTitleInfo optionally able to add the page id
Open, MediumPublicFeature

Description

Make ApiQueryBase::addTitleInfo optionally able to add the page id

But not by doing an unconditional db query (make the input get it first), as that'd be rather nasty...


Version: 1.20.x
Severity: enhancement

Details

Reference
bz28901

Related Objects

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:26 PM
bzimport set Reference to bz28901.

Bryan.TongMinh wrote:

Is there a way to store the page id in the Title object?

(In reply to comment #1)

Is there a way to store the page id in the Title object?

Looks like $mArticleID (set by Title::newFromRow)

Bryan.TongMinh wrote:

Ok, so that is easy.

We should first check though if all usages of addTitleInfo() use a Title that was constructed with a row that contains page_id so as to avoid running a new query for every title.

Indeed. May have to change things to use a faux Row object to get the information, but whatever

I was going to do that as part of the cleanup, at worst, in most cases, it'll be just pulling an extra column out of the database if it's not already done

Bryan.TongMinh wrote:

ApiImport is good
ApiPatrol is good
ApiPurge is not good, and is presumably already doing a query for every title because it is doing (new Title)->exists() in a loop.
ApiQuery gets its titles from ApiPageSet; need to check that.
ApiQueryAllimages is not good
ApiQueryAlllinks is not good
ApiQueryBacklinks is not good
... and many others are not good either. So somebody should take some time to fix all of them.

I'm assuming that all those not good ones need similar fixes, right? Would it be possible to do one and point to it here as documentation so I can add this bug to [[mw:Annoying Little Bug]]?

Ugh, that is a page on Mediawiki.org

(In reply to comment #5)

ApiQuery gets its titles from ApiPageSet; need to check that.

		$pageFlds = array(
			'page_namespace' => null,
			'page_title' => null,
			'page_id' => null,
		);

Looks good to me

Reverted r106523 in r106862; this is a strange abstraction violation and looks pretty weird to me.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM