Page MenuHomePhabricator

WikiPage::newFromId( $id=0 ) needlessly queries the database
Closed, ResolvedPublic

Description

WikiPage::newFromID( 0 ) actually queries the 'page' DB table to look up article ID 0. But MW code assumes that page_id == 0 means the page does not exist, e.g. Title sets mArticleId to 0 if article not found. So newFromID() could return null early if ( $id == 0 ).

One caller of this is ApiBase::getTitleOrPageId() , as a result API clients that pass pageid=0 hit the database, some even querying 'fromdbmaster'. AFTv5 is one example (bug 61164).


Version: 1.23.0
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=61164

Details

Reference
bz61166

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:58 AM
bzimport set Reference to bz61166.
bzimport added a subscriber: Unknown Object (MLST).

Change 112641 had a related patch set uploaded by Chad:
Return early when page id is less than 1

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