r88633 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88632‎ | r88633 | r88634 >
Date:04:28, 23 May 2011
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
* In core:
** Added hooks for custom RC/newpages filters
** Added tables,fields,and join_conds to SpecialNewPagesConditions hook
** Removed superflous $nameSpace logic in watchlist code
** Removed some copy-paste code for RC/watchlist filters
** Updates hooks.txt
* In FlaggedRevs:
* Added "hide reviewed edits" filter to RC/newpages
* Combined two handlers into modifyChangesListQuery. Removed is_array() check - always true now.
* Fixed onBeforePageDisplay() so that CSS worked on sp:Watchlist
* @TODO: remove $wgUseRCPatrol stuff...this gets us closer.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialNewpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1610,7 +1610,15 @@
16111611 &$special: NewPagesPager object (subclass of ReverseChronologicalPager)
16121612 $opts: FormOptions object containing special page options
16131613 &$conds: array of WHERE conditionals for query
 1614+&tables: array of tables to be queried
 1615+&$fields: array of columns to select
 1616+&$join_conds: join conditions for the tables
16141617
 1618+'SpecialNewPagesFilters': called after building form options at NewPages
 1619+$special: the special page object
 1620+&$filters: associative array of filter definitions. The keys are the HTML name/URL parameters.
 1621+Each key maps to an associative array with a 'msg' (message key) and a 'default' value.
 1622+
16151623 'SpecialPage_initList': called when setting up SpecialPage::$mList, use this
16161624 hook to remove a core special page
16171625 $list: list (array) of core special pages
@@ -1624,6 +1632,11 @@
16251633 &$title: If the hook returns false, a Title object to use instead of the
16261634 result from the normal query
16271635
 1636+'SpecialRecentChangesFilters': called after building form options at RecentChanges
 1637+$special: the special page object
 1638+&$filters: associative array of filter definitions. The keys are the HTML name/URL parameters.
 1639+Each key maps to an associative array with a 'msg' (message key) and a 'default' value.
 1640+
16281641 'SpecialRecentChangesPanel': called when building form options in
16291642 SpecialRecentChanges
16301643 &$extraOpts: array of added items, to which can be added
@@ -1636,7 +1649,7 @@
16371650 &$join_conds: join conditions for the tables
16381651 $opts: FormOptions for this request
16391652 &$query_options: array of options for the database request
1640 -&$select: String '*' or array of columns to select
 1653+&$select: Array of columns to select
16411654
16421655 'SpecialSearchGo': called when user clicked the "Go"
16431656 &$title: title object generated from the text entered by the user
@@ -1683,6 +1696,11 @@
16841697 use this to change the tables headers
16851698 $extTypes: associative array of extensions types
16861699
 1700+'SpecialWatchlistFilters': called after building form options at Watchlist
 1701+$special: the special page object
 1702+&$filters: associative array of filter definitions. The keys are the HTML name/URL parameters.
 1703+Each key maps to an associative array with a 'msg' (message key) and a 'default' value.
 1704+
16871705 'SpecialWatchlistQuery': called when building sql query for SpecialWatchlist
16881706 &$conds: array of WHERE conditionals for query
16891707 &$tables: array of tables to be queried
Index: trunk/phase3/includes/specials/SpecialNewpages.php
@@ -34,6 +34,7 @@
3535 * @var FormOptions
3636 */
3737 protected $opts;
 38+ protected $customFilters;
3839
3940 // Some internal settings
4041 protected $showNavigation = false;
@@ -59,6 +60,12 @@
6061 $opts->add( 'feed', '' );
6162 $opts->add( 'tagfilter', '' );
6263
 64+ $this->customFilters = array();
 65+ wfRunHooks( 'SpecialNewPagesFilters', array( $this, &$this->customFilters ) );
 66+ foreach( $this->customFilters as $key => $params ) {
 67+ $opts->add( $key, $params['default'] );
 68+ }
 69+
6370 // Set values
6471 $opts->fetchValuesFromRequest( $this->getRequest() );
6572 if ( $par ) $this->parseParams( $par );
@@ -167,13 +174,15 @@
168175 'hidebots' => 'rcshowhidebots',
169176 'hideredirs' => 'whatlinkshere-hideredirs'
170177 );
 178+ foreach ( $this->customFilters as $key => $params ) {
 179+ $filters[$key] = $params['msg'];
 180+ }
171181
172182 // Disable some if needed
173183 # @todo FIXME: Throws E_NOTICEs if not set; and doesn't obey hooks etc.
174184 if ( $wgGroupPermissions['*']['createpage'] !== true ) {
175185 unset( $filters['hideliu'] );
176186 }
177 -
178187 if ( !$this->getUser()->useNPPatrol() ) {
179188 unset( $filters['hidepatrolled'] );
180189 }
@@ -507,21 +516,23 @@
508517 }
509518
510519 // Allow changes to the New Pages query
511 - wfRunHooks( 'SpecialNewpagesConditions', array( &$this, $this->opts, &$conds ) );
 520+ $tables = array( 'recentchanges', 'page' );
 521+ $fields = array(
 522+ 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text',
 523+ 'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id', 'rc_deleted',
 524+ 'page_len AS length', 'page_latest AS rev_id', 'ts_tags'
 525+ );
 526+ $join_conds = array( 'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ) );
512527
 528+ wfRunHooks( 'SpecialNewpagesConditions',
 529+ array( &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ) );
 530+
513531 $info = array(
514 - 'tables' => array( 'recentchanges', 'page' ),
515 - 'fields' => array(
516 - 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user',
517 - 'rc_user_text', 'rc_comment', 'rc_timestamp', 'rc_patrolled',
518 - 'rc_id', 'rc_deleted', 'page_len AS length', 'page_latest AS rev_id',
519 - 'ts_tags'
520 - ),
521 - 'conds' => $conds,
522 - 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ),
523 - 'join_conds' => array(
524 - 'page' => array( 'INNER JOIN', 'page_id=rc_cur_id' ),
525 - ),
 532+ 'tables' => $tables,
 533+ 'fields' => $fields,
 534+ 'conds' => $conds,
 535+ 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ),
 536+ 'join_conds' => $join_conds
526537 );
527538
528539 // Empty array for fields, it'll be set by us anyway.
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -28,6 +28,7 @@
2929 */
3030 class SpecialRecentChanges extends IncludableSpecialPage {
3131 var $rcOptions, $rcSubpage;
 32+ protected $customFilters;
3233
3334 public function __construct( $name = 'Recentchanges' ) {
3435 parent::__construct( $name );
@@ -71,6 +72,13 @@
7273 global $wgRequest, $wgRCMaxAge;
7374
7475 $opts = $this->getDefaultOptions();
 76+
 77+ $this->customFilters = array();
 78+ wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) );
 79+ foreach( $this->customFilters as $key => $params ) {
 80+ $opts->add( $key, $params['default'] );
 81+ }
 82+
7583 $opts->fetchValuesFromRequest( $wgRequest );
7684 $opts->validateIntBounds( 'days', 1, $wgRCMaxAge / ( 3600 * 24 ) );
7785
@@ -789,28 +797,28 @@
790798
791799 // show/hide links
792800 $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
793 - $minorLink = $this->makeOptionsLink( $showhide[1 - $options['hideminor']],
794 - array( 'hideminor' => 1-$options['hideminor'] ), $nondefaults );
795 - $botLink = $this->makeOptionsLink( $showhide[1 - $options['hidebots']],
796 - array( 'hidebots' => 1-$options['hidebots'] ), $nondefaults );
797 - $anonsLink = $this->makeOptionsLink( $showhide[ 1 - $options['hideanons'] ],
798 - array( 'hideanons' => 1 - $options['hideanons'] ), $nondefaults );
799 - $liuLink = $this->makeOptionsLink( $showhide[1 - $options['hideliu']],
800 - array( 'hideliu' => 1-$options['hideliu'] ), $nondefaults );
801 - $patrLink = $this->makeOptionsLink( $showhide[1 - $options['hidepatrolled']],
802 - array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults );
803 - $myselfLink = $this->makeOptionsLink( $showhide[1 - $options['hidemyself']],
804 - array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults );
 801+ $filters = array(
 802+ 'hideminor' => 'rcshowhideminor',
 803+ 'hidebots' => 'rcshowhidebots',
 804+ 'hideanons' => 'rcshowhideanons',
 805+ 'hideliu' => 'rcshowhideliu',
 806+ 'hidepatrolled' => 'rcshowhidepatr',
 807+ 'hidemyself' => 'rcshowhidemine'
 808+ );
 809+ foreach ( $this->customFilters as $key => $params ) {
 810+ $filters[$key] = $params['msg'];
 811+ }
 812+ // Disable some if needed
 813+ if ( !$this->getUser()->useRCPatrol() ) {
 814+ unset( $filters['hidepatrolled'] );
 815+ }
805816
806 - $links[] = wfMsgHtml( 'rcshowhideminor', $minorLink );
807 - $links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
808 - $links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink );
809 - $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
810 - if( $this->getUser()->useRCPatrol() ) {
811 - $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
 817+ $links = array();
 818+ foreach ( $filters as $key => $msg ) {
 819+ $link = $this->makeOptionsLink( $showhide[1 - $options[$key]],
 820+ array( $key => 1-$options[$key] ), $nondefaults );
 821+ $links[] = wfMsgHtml( $msg, $link );
812822 }
813 - $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
814 - $hl = $wgLang->pipeList( $links );
815823
816824 // show from this onward link
817825 $now = $wgLang->timeanddate( wfTimestampNow(), true );
@@ -819,7 +827,7 @@
820828 );
821829
822830 $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
823 - $cl, $dl, $hl );
 831+ $cl, $dl, $wgLang->pipeList( $links ) );
824832 $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl );
825833 return "{$note}$rclinks<br />$rclistfrom";
826834 }
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -21,6 +21,7 @@
2222 * @ingroup SpecialPage Watchlist
2323 */
2424 class SpecialWatchlist extends SpecialPage {
 25+ protected $customFilters;
2526
2627 /**
2728 * Constructor
@@ -109,6 +110,7 @@
110111 return;
111112 }
112113
 114+ // @TODO: use FormOptions!
113115 $defaults = array(
114116 /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
115117 /* bool */ 'hideMinor' => (int)$wgUser->getBoolOption( 'watchlisthideminor' ),
@@ -120,6 +122,11 @@
121123 /* ? */ 'namespace' => 'all',
122124 /* ? */ 'invert' => false,
123125 );
 126+ $this->customFilters = array();
 127+ wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
 128+ foreach( $this->customFilters as $key => $params ) {
 129+ $defaults[$key] = $params['msg'];
 130+ }
124131
125132 # Extract variables from the request, falling back to user preferences or
126133 # other default values if these don't exist
@@ -132,20 +139,24 @@
133140 $prefs['hidepatrolled' ] = $wgUser->getBoolOption( 'watchlisthidepatrolled' );
134141
135142 # Get query variables
136 - $days = $wgRequest->getVal( 'days' , $prefs['days'] );
137 - $hideMinor = $wgRequest->getBool( 'hideMinor', $prefs['hideminor'] );
138 - $hideBots = $wgRequest->getBool( 'hideBots' , $prefs['hidebots'] );
139 - $hideAnons = $wgRequest->getBool( 'hideAnons', $prefs['hideanons'] );
140 - $hideLiu = $wgRequest->getBool( 'hideLiu' , $prefs['hideliu'] );
141 - $hideOwn = $wgRequest->getBool( 'hideOwn' , $prefs['hideown'] );
142 - $hidePatrolled = $wgRequest->getBool( 'hidePatrolled' , $prefs['hidepatrolled'] );
 143+ $values = array();
 144+ $values['days'] = $wgRequest->getVal( 'days', $prefs['days'] );
 145+ $values['hideMinor'] = (int)$wgRequest->getBool( 'hideMinor', $prefs['hideminor'] );
 146+ $values['hideBots'] = (int)$wgRequest->getBool( 'hideBots' , $prefs['hidebots'] );
 147+ $values['hideAnons'] = (int)$wgRequest->getBool( 'hideAnons', $prefs['hideanons'] );
 148+ $values['hideLiu'] = (int)$wgRequest->getBool( 'hideLiu' , $prefs['hideliu'] );
 149+ $values['hideOwn'] = (int)$wgRequest->getBool( 'hideOwn' , $prefs['hideown'] );
 150+ $values['hidePatrolled'] = (int)$wgRequest->getBool( 'hidePatrolled', $prefs['hidepatrolled'] );
 151+ foreach( $this->customFilters as $key => $params ) {
 152+ $values[$key] = (int)$wgRequest->getBool( $key );
 153+ }
143154
144155 # Get namespace value, if supplied, and prepare a WHERE fragment
145156 $nameSpace = $wgRequest->getIntOrNull( 'namespace' );
146157 $invert = $wgRequest->getIntOrNull( 'invert' );
147 - if( !is_null( $nameSpace ) ) {
148 - $nameSpace = intval( $nameSpace );
149 - if( $invert && $nameSpace !== 'all' ) {
 158+ if ( !is_null( $nameSpace ) ) {
 159+ $nameSpace = intval( $nameSpace ); // paranioa
 160+ if ( $invert ) {
150161 $nameSpaceClause = "rc_namespace != $nameSpace";
151162 } else {
152163 $nameSpaceClause = "rc_namespace = $nameSpace";
@@ -154,6 +165,8 @@
155166 $nameSpace = '';
156167 $nameSpaceClause = '';
157168 }
 169+ $values['namespace'] = $nameSpace;
 170+ $values['invert'] = $invert;
158171
159172 $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
160173 $recentchanges = $dbr->tableName( 'recentchanges' );
@@ -164,30 +177,24 @@
165178 // but treated together
166179 $nitems = floor( $watchlistCount / 2 );
167180
168 - if( is_null( $days ) || !is_numeric( $days ) ) {
 181+ if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
169182 $big = 1000; /* The magical big */
170183 if( $nitems > $big ) {
171184 # Set default cutoff shorter
172 - $days = $defaults['days'] = (12.0 / 24.0); # 12 hours...
 185+ $values['days'] = $defaults['days'] = (12.0 / 24.0); # 12 hours...
173186 } else {
174 - $days = $defaults['days']; # default cutoff for shortlisters
 187+ $values['days'] = $defaults['days']; # default cutoff for shortlisters
175188 }
176189 } else {
177 - $days = floatval( $days );
 190+ $values['days'] = floatval( $values['days'] );
178191 }
179192
180193 // Dump everything here
181194 $nondefaults = array();
 195+ foreach ( $defaults as $name => $defValue ) {
 196+ wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults );
 197+ }
182198
183 - wfAppendToArrayIfNotDefault( 'days' , $days , $defaults, $nondefaults);
184 - wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults );
185 - wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots , $defaults, $nondefaults);
186 - wfAppendToArrayIfNotDefault( 'hideAnons', (int)$hideAnons, $defaults, $nondefaults );
187 - wfAppendToArrayIfNotDefault( 'hideLiu' , (int)$hideLiu , $defaults, $nondefaults );
188 - wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn , $defaults, $nondefaults);
189 - wfAppendToArrayIfNotDefault( 'namespace', $nameSpace , $defaults, $nondefaults);
190 - wfAppendToArrayIfNotDefault( 'hidePatrolled', (int)$hidePatrolled, $defaults, $nondefaults );
191 -
192199 if( $nitems == 0 ) {
193200 $wgOut->addWikiMsg( 'nowatchlist' );
194201 return;
@@ -196,8 +203,8 @@
197204 # Possible where conditions
198205 $conds = array();
199206
200 - if( $days > 0 ) {
201 - $conds[] = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'";
 207+ if( $values['days'] > 0 ) {
 208+ $conds[] = "rc_timestamp > '".$dbr->timestamp( time() - intval( $values['days'] * 86400 ) )."'";
202209 }
203210
204211 # If the watchlist is relatively short, it's simplest to zip
@@ -209,25 +216,25 @@
210217 # Up estimate of watched items by 15% to compensate for talk pages...
211218
212219 # Toggles
213 - if( $hideOwn ) {
 220+ if( $values['hideOwn'] ) {
214221 $conds[] = "rc_user != $uid";
215222 }
216 - if( $hideBots ) {
 223+ if( $values['hideBots'] ) {
217224 $conds[] = 'rc_bot = 0';
218225 }
219 - if( $hideMinor ) {
 226+ if( $values['hideMinor'] ) {
220227 $conds[] = 'rc_minor = 0';
221228 }
222 - if( $hideLiu ) {
 229+ if( $values['hideLiu'] ) {
223230 $conds[] = 'rc_user = 0';
224231 }
225 - if( $hideAnons ) {
 232+ if( $values['hideAnons'] ) {
226233 $conds[] = 'rc_user != 0';
227234 }
228 - if ( $wgUser->useRCPatrol() && $hidePatrolled ) {
 235+ if ( $wgUser->useRCPatrol() && $values['hidePatrolled'] ) {
229236 $conds[] = 'rc_patrolled != 1';
230237 }
231 - if( $nameSpaceClause ) {
 238+ if ( $nameSpaceClause ) {
232239 $conds[] = $nameSpaceClause;
233240 }
234241
@@ -299,34 +306,45 @@
300307 /* Start bottom header */
301308
302309 $wlInfo = '';
303 - if( $days >= 1 ) {
 310+ if( $values['days'] >= 1 ) {
304311 $wlInfo = wfMsgExt( 'rcnote', 'parseinline',
305312 $wgLang->formatNum( $numRows ),
306 - $wgLang->formatNum( $days ),
 313+ $wgLang->formatNum( $values['days'] ),
307314 $wgLang->timeAndDate( wfTimestampNow(), true ),
308315 $wgLang->date( wfTimestampNow(), true ),
309316 $wgLang->time( wfTimestampNow(), true )
310317 ) . '<br />';
311 - } elseif( $days > 0 ) {
 318+ } elseif( $values['days'] > 0 ) {
312319 $wlInfo = wfMsgExt( 'wlnote', 'parseinline',
313320 $wgLang->formatNum( $numRows ),
314 - $wgLang->formatNum( round( $days * 24 ) )
 321+ $wgLang->formatNum( round( $values['days'] * 24 ) )
315322 ) . '<br />';
316323 }
317324
318 - $cutofflinks = "\n" . self::cutoffLinks( $days, 'Watchlist', $nondefaults ) . "<br />\n";
 325+ $cutofflinks = "\n" . self::cutoffLinks( $values['days'], 'Watchlist', $nondefaults ) . "<br />\n";
319326
320327 $thisTitle = SpecialPage::getTitleFor( 'Watchlist' );
321328
322329 # Spit out some control panel links
323 - $links[] = self::showHideLink( $nondefaults, 'rcshowhideminor', 'hideMinor', $hideMinor );
324 - $links[] = self::showHideLink( $nondefaults, 'rcshowhidebots', 'hideBots', $hideBots );
325 - $links[] = self::showHideLink( $nondefaults, 'rcshowhideanons', 'hideAnons', $hideAnons );
326 - $links[] = self::showHideLink( $nondefaults, 'rcshowhideliu', 'hideLiu', $hideLiu );
327 - $links[] = self::showHideLink( $nondefaults, 'rcshowhidemine', 'hideOwn', $hideOwn );
 330+ $filters = array(
 331+ 'hideMinor' => 'rcshowhideminor',
 332+ 'hideBots' => 'rcshowhidebots',
 333+ 'hideAnons' => 'rcshowhideanons',
 334+ 'hideLiu' => 'rcshowhideliu',
 335+ 'hideOwn' => 'rcshowhidemine',
 336+ 'hidePatrolled' => 'rcshowhidepatr'
 337+ );
 338+ foreach ( $this->customFilters as $key => $params ) {
 339+ $filters[$key] = $params['msg'];
 340+ }
 341+ // Disable some if needed
 342+ if ( !$wgUser->useNPPatrol() ) {
 343+ unset( $filters['hidePatrolled'] );
 344+ }
328345
329 - if( $wgUser->useRCPatrol() ) {
330 - $links[] = self::showHideLink( $nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled );
 346+ $links = array();
 347+ foreach( $filters as $name => $msg ) {
 348+ $links[] = self::showHideLink( $nondefaults, $msg, $name, $values[$name] );
331349 }
332350
333351 # Namespace filter and put the whole form together.
@@ -339,22 +357,12 @@
340358 $form .= Xml::namespaceSelector( $nameSpace, '' ) . '&#160;';
341359 $form .= Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $invert ) . '&#160;';
342360 $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . '</p>';
343 - $form .= Html::hidden( 'days', $days );
344 - if( $hideMinor ) {
345 - $form .= Html::hidden( 'hideMinor', 1 );
 361+ $form .= Html::hidden( 'days', $values['days'] );
 362+ foreach ( $filters as $key => $msg ) {
 363+ if ( $values[$key] ) {
 364+ $form .= Html::hidden( $key, 1 );
 365+ }
346366 }
347 - if( $hideBots ) {
348 - $form .= Html::hidden( 'hideBots', 1 );
349 - }
350 - if( $hideAnons ) {
351 - $form .= Html::hidden( 'hideAnons', 1 );
352 - }
353 - if( $hideLiu ) {
354 - $form .= Html::hidden( 'hideLiu', 1 );
355 - }
356 - if( $hideOwn ) {
357 - $form .= Html::hidden( 'hideOwn', 1 );
358 - }
359367 $form .= Xml::closeElement( 'form' );
360368 $form .= Xml::closeElement( 'fieldset' );
361369 $wgOut->addHTML( $form );
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -421,10 +421,16 @@
422422 $wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine';
423423 $wgHooks['LocalFile::getHistory'][] = 'FlaggedRevsUIHooks::addToFileHistQuery';
424424 $wgHooks['ImagePageFileHistoryLine'][] = 'FlaggedRevsUIHooks::addToFileHistLine';
 425+# Select extra info & filter items in RC
 426+$wgHooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::modifyRecentChangesQuery';
 427+$wgHooks['SpecialNewpagesConditions'][] = 'FlaggedRevsUIHooks::modifyNewPagesQuery';
 428+$wgHooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::modifyChangesListQuery';
425429 # Mark items in RC
426 -$wgHooks['SpecialRecentChangesQuery'][] = 'FlaggedRevsUIHooks::addToRCQuery';
427 -$wgHooks['SpecialWatchlistQuery'][] = 'FlaggedRevsUIHooks::addToWatchlistQuery';
428430 $wgHooks['ChangesListInsertArticleLink'][] = 'FlaggedRevsUIHooks::addToChangeListLine';
 431+# RC filter UIs
 432+$wgHooks['SpecialNewPagesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
 433+$wgHooks['SpecialRecentChangesFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
 434+$wgHooks['SpecialWatchlistFilters'][] = 'FlaggedRevsUIHooks::addHideReviewedFilter';
429435 # Page review on edit
430436 $wgHooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevsUIHooks::injectPostEditURLParams';
431437 # Diff-to-stable
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
@@ -89,9 +89,6 @@
9090 */
9191 protected static function injectStyleForSpecial( &$out ) {
9292 $title = $out->getTitle();
93 - if ( $title->getNamespace() !== NS_SPECIAL ) {
94 - return true;
95 - }
9693 $spPages = array( 'UnreviewedPages', 'PendingChanges', 'ProblemChanges',
9794 'Watchlist', 'Recentchanges', 'Contributions', 'Recentchangeslinked' );
9895 foreach ( $spPages as $key ) {
@@ -107,7 +104,7 @@
108105 * Add tag notice, CSS/JS, and set robots policy
109106 */
110107 public static function onBeforePageDisplay( &$out, &$skin ) {
111 - if ( $out->isArticleRelated() ) {
 108+ if ( $out->getTitle()->getNamespace() != NS_SPECIAL ) {
112109 $view = FlaggedPageView::singleton();
113110 $view->displayTag(); // show notice bar/icon in subtitle
114111 $view->setRobotPolicy(); // set indexing policy
@@ -332,6 +329,11 @@
333330 return true;
334331 }
335332
 333+ public static function addHideReviewedFilter( $specialPage, &$filters ) {
 334+ $filters['hideReviewed'] = array( 'msg' => 'flaggedrevs-hidereviewed', 'default' => false );
 335+ return true;
 336+ }
 337+
336338 public static function addToHistQuery( HistoryPager $pager, array &$queryInfo ) {
337339 $flaggedArticle = FlaggedPage::getArticleInstance( $pager->getArticle() );
338340 # Non-content pages cannot be validated. Stable version must exist.
@@ -397,27 +399,28 @@
398400 return true;
399401 }
400402
401 - public static function addToRCQuery(
402 - &$conds, array &$tables, array &$join_conds, $opts, &$query_opts, &$select
 403+ public static function modifyRecentChangesQuery(
 404+ &$conds, &$tables, &$join_conds, $opts, &$query_opts, &$fields
403405 ) {
404 - $tables[] = 'flaggedpages';
405 - $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' );
406 - if ( is_array( $select ) ) { // RCL
407 - $select[] = 'fp_stable';
408 - $select[] = 'fp_pending_since';
409 - }
410 - return true;
 406+ return self::modifyChangesListQuery( $conds, $tables, $join_conds, $fields );
411407 }
412408
413 - public static function addToWatchlistQuery(
414 - &$conds, array &$tables, array &$join_conds, array &$fields
 409+ public static function modifyNewPagesQuery(
 410+ $specialPage, $opts, &$conds, &$tables, &$fields, &$join_conds
415411 ) {
416 - global $wgUser;
417 - if ( $wgUser->isAllowed( 'review' ) ) {
418 - $fields[] = 'fp_stable';
419 - $fields[] = 'fp_pending_since';
420 - $tables[] = 'flaggedpages';
421 - $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' );
 412+ return self::modifyChangesListQuery( $conds, $tables, $join_conds, $fields );
 413+ }
 414+
 415+ public static function modifyChangesListQuery(
 416+ array &$conds, array &$tables, array &$join_conds, array &$fields
 417+ ) {
 418+ global $wgRequest;
 419+ $tables[] = 'flaggedpages';
 420+ $fields[] = 'fp_stable';
 421+ $fields[] = 'fp_pending_since';
 422+ $join_conds['flaggedpages'] = array( 'LEFT JOIN', 'fp_page_id = rc_cur_id' );
 423+ if ( $wgRequest->getBool( 'hidereviewed' ) ) {
 424+ $conds[] = 'rc_timestamp >= fp_pending_since OR fp_stable IS NULL';
422425 }
423426 return true;
424427 }
Index: trunk/extensions/FlaggedRevs/presentation/language/FlaggedRevs.i18n.php
@@ -32,6 +32,7 @@
3333 'flaggedrevs-prefs-watch' => 'Add pages I review to my watchlist',
3434 'flaggedrevs-prefs-editdiffs' => 'Show the pending changes diff when editing pages',
3535 'flaggedrevs-prefs-viewdiffs' => 'Show the pending changes diff when viewing the latest pending revision',
 36+ 'flaggedrevs-hidereviewed' => '$1 reviewed edits',
3637 'group-editor' => 'Editors',
3738 'group-editor-member' => 'editor',
3839 'group-reviewer' => 'Reviewers',

Follow-up revisions

RevisionCommit summaryAuthorDate
r88638Follow-up r88633:...aaron13:47, 23 May 2011
r108800r88633: lazy-load 'customFilters' field in SpecialRecentChanges. Almost every...aaron09:14, 13 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   08:49, 13 January 2012

Reproduce-able notices with urls like: http://translatewiki.net/w/i.php?target=1%29%20declare%20%40q%20varchar%288000%29%20select%20%40q%20%3D%200x57414954464F522044454C4159202730303A30303A313527%20exec%28%40q%29%20--&title=Special:RecentChangesLinked/Main_Page&feed=atom

Notices like: [13-Jan-2012 08:47:52] PHP Warning: Invalid argument supplied for foreach() in /www/w/includes/specials/SpecialRecentchanges.php on line 816

The way the customFilters is used elsewhere but depends on call to setup() to have it initialized looks very fragile.

Status & tagging log