r71970 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71969‎ | r71970 | r71971 >
Date:19:07, 30 August 2010
Author:demon
Status:ok (Comments)
Tags:
Comment:
Tweak SpecialRecentChangesQuery hook. Need to be able to modify selected fields on RCL (part 1 for bug 23916)
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchangeslinked.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1564,6 +1564,7 @@
15651565 &$join_conds: join conditions for the tables
15661566 $opts: FormOptions for this request
15671567 &$query_options: array of options for the database request
 1568+&$select: String '*' or array of columns to select
15681569
15691570 'SpecialSearchGomatch': called when user clicked the "Go" button and the target
15701571 exists
Index: trunk/phase3/includes/specials/SpecialRecentchangeslinked.php
@@ -114,7 +114,7 @@
115115 $query_options, $opts['tagfilter'] );
116116 }
117117
118 - if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options ) ) )
 118+ if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$select ) ) )
119119 return false;
120120
121121 if( $ns == NS_CATEGORY && !$showlinkedto ) {
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -311,6 +311,7 @@
312312 $dbr = wfGetDB( DB_SLAVE );
313313 $limit = $opts['limit'];
314314 $namespace = $opts['namespace'];
 315+ $select = '*';
315316 $invert = $opts['invert'];
316317
317318 // JOIN on watchlist for users
@@ -333,7 +334,7 @@
334335 );
335336 }
336337
337 - if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options ) ) )
 338+ if ( !wfRunHooks( 'SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$select ) ) )
338339 return false;
339340
340341 // Don't use the new_namespace_time timestamp index if:
@@ -353,7 +354,7 @@
354355 // We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
355356 } else {
356357 // New pages
357 - $sqlNew = $dbr->selectSQLText( $tables, '*',
 358+ $sqlNew = $dbr->selectSQLText( $tables, $select,
358359 array( 'rc_new' => 1 ) + $conds,
359360 __METHOD__,
360361 array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,

Follow-up revisions

RevisionCommit summaryAuthorDate
r71971(bug 23916) Pending changes in related changesdemon19:08, 30 August 2010
r76485MFT r70559, r71970demon23:13, 10 November 2010
r76679MFT r70559, r71970 (SpecialRecentChangesQuery changes)robla08:34, 15 November 2010

Comments

#Comment by Aaron Schulz (talk | contribs)   03:49, 11 November 2010

Does anything other than FR use this hook? They may need updated if so.

#Comment by 😂 (talk | contribs)   21:26, 12 November 2010

Extra parameters should be safely ignored.

#Comment by Aaron Schulz (talk | contribs)   23:21, 12 November 2010

Not here. Suppose an extension joined on a table. Selecting '*' would of course select the new columns, but now it selects $select, which would fail if no columns were added to $select.

#Comment by Aaron Schulz (talk | contribs)   23:30, 12 November 2010

OK, never mind, this is confusing. $select starts as a string in RC but an array in RCL. I guess as long as extensions ignore $select if it's not an array and append if it is, then works.

Status & tagging log