r86433 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86432‎ | r86433 | r86434 >
Date:20:39, 19 April 2011
Author:aaron
Status:ok
Tags:
Comment:
Fixed doMainQuery() so that it doesn't mindlessly select all columns on 2-4 (more with extensions) tables. No extensions in SVN should need updating. All except FlaggedRevs just filter with conditions, and FlaggedRevs already adds its required columns to to fields array (which was basically unused before).
Modified paths:
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -319,31 +319,35 @@
320320 $dbr = wfGetDB( DB_SLAVE );
321321 $limit = $opts['limit'];
322322 $namespace = $opts['namespace'];
323 - $select = '*';
324323 $invert = $opts['invert'];
325324
 325+ $fields = array( $dbr->tableName( 'recentchanges' ) . '.*' ); // all rc columns
326326 // JOIN on watchlist for users
327 - if( $uid ) {
 327+ if ( $uid ) {
328328 $tables[] = 'watchlist';
 329+ $fields[] = 'wl_user';
 330+ $fields[] = 'wl_notificationtimestamp';
329331 $join_conds['watchlist'] = array('LEFT JOIN',
330332 "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
331333 }
332 - if ($this->getUser()->isAllowed("rollback")) {
 334+ if ( $this->getUser()->isAllowed( 'rollback' ) ) {
333335 $tables[] = 'page';
 336+ $fields[] = 'page_latest';
334337 $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
335338 }
336339 if ( !$this->including() ) {
337340 // Tag stuff.
338341 // Doesn't work when transcluding. See bug 23293
339 - $fields = array();
340 - // Fields are * in this case, so let the function modify an empty array to keep it happy.
341342 ChangeTags::modifyDisplayQuery(
342343 $tables, $fields, $conds, $join_conds, $query_options, $opts['tagfilter']
343344 );
344345 }
345346
346 - if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$select ) ) )
 347+ if ( !wfRunHooks( 'SpecialRecentChangesQuery',
 348+ array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) ) )
 349+ {
347350 return false;
 351+ }
348352
349353 // Don't use the new_namespace_time timestamp index if:
350354 // (a) "All namespaces" selected
@@ -355,21 +359,21 @@
356360 || $opts['tagfilter'] != ''
357361 || !$dbr->unionSupportsOrderAndLimit() )
358362 {
359 - $res = $dbr->select( $tables, '*', $conds, __METHOD__,
 363+ $res = $dbr->select( $tables, $fields, $conds, __METHOD__,
360364 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) +
361365 $query_options,
362366 $join_conds );
363367 // We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
364368 } else {
365369 // New pages
366 - $sqlNew = $dbr->selectSQLText( $tables, $select,
 370+ $sqlNew = $dbr->selectSQLText( $tables, $fields,
367371 array( 'rc_new' => 1 ) + $conds,
368372 __METHOD__,
369373 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,
370374 'USE INDEX' => array('recentchanges' => 'rc_timestamp') ),
371375 $join_conds );
372376 // Old pages
373 - $sqlOld = $dbr->selectSQLText( $tables, '*',
 377+ $sqlOld = $dbr->selectSQLText( $tables, $fields,
374378 array( 'rc_new' => 0 ) + $conds,
375379 __METHOD__,
376380 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,

Status & tagging log