Return early when page id is less than 1

Wasteful DB query when we know the page won't exist.

Bug: 61166
Change-Id: I8943b4dec5088dadffefbd74f54653cb09043b7c
This commit is contained in:
Chad Horohoe 2014-02-10 21:52:01 -08:00
parent f1a1cd5d79
commit d7f465f7e8

View file

@ -142,6 +142,11 @@ class WikiPage implements Page, IDBAccessObject {
* @return WikiPage|null
*/
public static function newFromID( $id, $from = 'fromdb' ) {
// page id's are never 0 or negative, see bug 61166
if ( $id < 1 ) {
return;
}
$from = self::convertSelectType( $from );
$db = wfGetDB( $from === self::READ_LATEST ? DB_MASTER : DB_SLAVE );
$row = $db->selectRow( 'page', self::selectFields(), array( 'page_id' => $id ), __METHOD__ );