From: Aaron Schulz Date: Fri, 27 Mar 2009 10:22:30 +0000 (+0000) Subject: Make Title::newFromID only use one query X-Git-Tag: 1.31.0-rc.0~42327 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=c21a5a0edd03d02c48413224790e9197411a0901;p=lhc%2Fweb%2Fwiklou.git Make Title::newFromID only use one query --- diff --git a/includes/Title.php b/includes/Title.php index f6c0d5de6c..d4bf7c2206 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -179,20 +179,15 @@ class Title { /** * Create a new Title from an article ID * - * @todo This is inefficiently implemented, the page row is requested - * but not used for anything else - * * @param $id \type{\int} the page_id corresponding to the Title to create * @param $flags \type{\int} use GAID_FOR_UPDATE to use master * @return \type{Title} the new object, or NULL on an error */ public static function newFromID( $id, $flags = 0 ) { - $fname = 'Title::newFromID'; $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); - $row = $db->selectRow( 'page', array( 'page_namespace', 'page_title' ), - array( 'page_id' => $id ), $fname ); - if ( $row !== false ) { - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); + $row = $db->selectRow( 'page', '*', array( 'page_id' => $id ), __METHOD__ ); + if( $row !== false ) { + $title = Title::newFromRow( $row ); } else { $title = NULL; }