r44881 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44880‎ | r44881 | r44882 >
Date:21:31, 21 December 2008
Author:aaron
Status:ok (Comments)
Tags:
Comment:
*Replace crappy BeforeWatchlist hook
*Updated LQT accordingly
*Will add flaggedrevs function to this shortly
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtFunctions.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -505,13 +505,6 @@
506506 &$parser: Parser object
507507 &$ig: ImageGallery object
508508
509 -'BeforeWatchlist': Override watchlist display or add extra SQL clauses.
510 -$nondefaults: Assoc array with the following keys:
511 - days, hideOwn, hideBots, hideMinor, namespace
512 -$wgUser: wgUser.
513 -&$hookSql: a string which will be inserted without sanitation into the SQL query
514 - used to get the watchlist, at the end of the WHERE part.
515 -
516509 'BlockIp': before an IP address or user is blocked
517510 $block: the Block object about to be saved
518511 $user: the user _doing_ the block (not the one being blocked)
@@ -1239,7 +1232,7 @@
12401233 $opts: FormOptions for this request
12411234
12421235 'SpecialRecentChangesQuery': called when building sql query for SpecialRecentChanges
1243 -&$conds: array of where conditionals for query
 1236+&$conds: array of WHERE conditionals for query
12441237 &$tables: array of tables to be queried
12451238 &$join_conds: join conditions for the tables
12461239 $opts: FormOptions for this request
@@ -1258,6 +1251,12 @@
12591252 'SpecialVersionExtensionTypes': called when generating the extensions credits, use this to change the tables headers
12601253 $extTypes: associative array of extensions types
12611254
 1255+'SpecialWatchlistQuery': called when building sql query for SpecialWatchlist
 1256+&$conds: array of WHERE conditionals for query
 1257+&$tables: array of tables to be queried
 1258+&$join_conds: join conditions for the tables
 1259+&$fields: array of query fields
 1260+
12621261 'TitleArrayFromResult': called when creating an TitleArray object from a database result
12631262 &$titleArray: set this to an object to override the default object returned
12641263 $res: database result used to create the object
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -128,17 +128,12 @@
129129 wfAppendToArrayIfNotDefault( 'namespace', $nameSpace , $defaults, $nondefaults);
130130 wfAppendToArrayIfNotDefault( 'hidePatrolled', (int)$hidePatrolled, $defaults, $nondefaults );
131131
132 - $hookSql = "";
133 - if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) {
134 - return;
135 - }
136 -
137 - if($nitems == 0) {
 132+ if( $nitems == 0 ) {
138133 $wgOut->addWikiMsg( 'nowatchlist' );
139134 return;
140135 }
141136
142 - if ( $days <= 0 ) {
 137+ if( $days <= 0 ) {
143138 $andcutoff = '';
144139 } else {
145140 $andcutoff = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'";
@@ -217,8 +212,9 @@
218213 if( $andHideAnons ) $conds[] = $andHideAnons;
219214 if( $andHidePatrolled ) $conds[] = $andHidePatrolled;
220215 if( $nameSpaceClause ) $conds[] = $nameSpaceClause;
221 - if( $hookSql ) $conds[] = $hookSql;
222216
 217+ wfRunHooks('SpecialWatchlistQuery', array(&$conds,&$tables,&$join_conds,&$fields) );
 218+
223219 $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
224220 $numRows = $dbr->numRows( $res );
225221
Index: trunk/extensions/LiquidThreads/LqtFunctions.php
@@ -63,15 +63,15 @@
6464 efThreadTableHelper($st, $indent + 1);
6565 }
6666
67 -function wfLqtBeforeWatchlistHook( $options, $user, &$hook_sql ) {
68 - global $wgOut;
 67+function wfLqtBeforeWatchlistHook( &$conds, &$tables, &$join_conds, &$fields ) {
 68+ global $wgOut, $wgUser;
6969
70 - $hook_sql = "AND page_namespace != " . NS_LQT_THREAD;
 70+ $conds[] = "page_namespace != " . NS_LQT_THREAD;
7171
72 - $talkpage_messages = NewMessages::newUserMessages($user);
 72+ $talkpage_messages = NewMessages::newUserMessages($wgUser);
7373 $tn = count($talkpage_messages);
7474
75 - $watch_messages = NewMessages::watchedThreadsForUser($user);
 75+ $watch_messages = NewMessages::watchedThreadsForUser($wgUser);
7676 $wn = count($watch_messages);
7777
7878 if( $tn == 0 && $wn == 0 )
Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -36,7 +36,7 @@
3737 $wgExtensionMessagesFiles['LiquidThreads'] = $dir . 'Lqt.i18n.php';
3838 $wgExtensionAliasesFiles['LiquidThreads'] = $dir . 'Lqt.alias.php';
3939
40 -$wgHooks['BeforeWatchlist'][] = 'wfLqtBeforeWatchlistHook';
 40+$wgHooks['SpecialWatchlistQuery'][] = 'wfLqtBeforeWatchlistHook';
4141 $wgHooks['MediaWikiPerformAction'][] = 'LqtDispatch::tryPage';
4242 $wgHooks['SpecialMovepageAfterMove'][] = 'LqtDispatch::onPageMove';
4343 $wgHooks['LinkerMakeLinkObj'][] = 'LqtDispatch::makeLinkObj';

Follow-up revisions

RevisionCommit summaryAuthorDate
r44973Follow-up to r44881 -- add note to RELEASE-NOTES about removed/replaced hookbrion21:10, 23 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   21:10, 23 December 2008

Added RELEASE-NOTES on the removed hook in r44973

Status & tagging log