r48912 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48911‎ | r48912 | r48913 >
Date:10:22, 27 March 2009
Author:aaron
Status:ok
Tags:
Comment:
Make Title::newFromID only use one query
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -179,20 +179,15 @@
180180 /**
181181 * Create a new Title from an article ID
182182 *
183 - * @todo This is inefficiently implemented, the page row is requested
184 - * but not used for anything else
185 - *
186183 * @param $id \type{\int} the page_id corresponding to the Title to create
187184 * @param $flags \type{\int} use GAID_FOR_UPDATE to use master
188185 * @return \type{Title} the new object, or NULL on an error
189186 */
190187 public static function newFromID( $id, $flags = 0 ) {
191 - $fname = 'Title::newFromID';
192188 $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
193 - $row = $db->selectRow( 'page', array( 'page_namespace', 'page_title' ),
194 - array( 'page_id' => $id ), $fname );
195 - if ( $row !== false ) {
196 - $title = Title::makeTitle( $row->page_namespace, $row->page_title );
 189+ $row = $db->selectRow( 'page', '*', array( 'page_id' => $id ), __METHOD__ );
 190+ if( $row !== false ) {
 191+ $title = Title::newFromRow( $row );
197192 } else {
198193 $title = NULL;
199194 }

Status & tagging log