Merge "Fix deprecated hooks not having a non-deprecated alternative"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 30 Jul 2014 13:53:36 +0000 (13:53 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 30 Jul 2014 13:53:36 +0000 (13:53 +0000)
1  2 
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php

@@@ -53,8 -53,7 +53,8 @@@ abstract class ChangesListSpecialPage e
                $opts = $this->getOptions();
                if ( $rows === false ) {
                        if ( !$this->including() ) {
 -                              $this->doHeader( $opts );
 +                              $this->doHeader( $opts, 0 );
 +                              $this->getOutput()->setStatusCode( 404 );
                        }
  
                        return;
                        ''
                );
  
-               if ( !wfRunHooks( 'ChangesListSpecialPageQuery',
-                       array( $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) )
+               if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
+                       $opts )
                ) {
                        return false;
                }
                );
        }
  
+       protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) {
+               return wfRunHooks(
+                       'ChangesListSpecialPageQuery',
+                       array( $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts )
+               );
+       }
        /**
         * Return a DatabaseBase object for reading
         *
        public function webOutput( $rows, $opts ) {
                if ( !$this->including() ) {
                        $this->outputFeedLinks();
 -                      $this->doHeader( $opts );
 +                      $this->doHeader( $opts, $rows->numRows() );
                }
  
                $this->outputChangesList( $rows, $opts );
        abstract public function outputChangesList( $rows, $opts );
  
        /**
 -       * Return the text to be displayed above the changes
 +       * Set the text to be displayed above the changes
         *
         * @param FormOptions $opts
 -       * @return string XHTML
 +       * @param int $numRows Number of rows in the result to show after this header
         */
 -      public function doHeader( $opts ) {
 +      public function doHeader( $opts, $numRows ) {
                $this->setTopText( $opts );
  
                // @todo Lots of stuff should be done here.
@@@ -229,9 -229,8 +229,8 @@@ class SpecialRecentChanges extends Chan
                        $opts['tagfilter']
                );
  
-               if ( !wfRunHooks( 'SpecialRecentChangesQuery',
-                       array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ),
-                       '1.23' )
+               if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
+                       $opts )
                ) {
                        return false;
                }
                return $rows;
        }
  
+       protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) {
+               return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
+                       && wfRunHooks(
+                               'SpecialRecentChangesQuery',
+                               array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ),
+                               '1.23'
+                       );
+       }
        public function outputFeedLinks() {
                $this->addFeedLinks( $this->getFeedQuery() );
        }
                                $this->msg( 'recentchanges-noresult' )->parse() .
                                '</div>'
                        );
 +                      if ( !$this->including() ) {
 +                              $this->getOutput()->setStatusCode( 404 );
 +                      }
                } else {
                        $this->getOutput()->addHTML( $rclistOutput );
                }
        }
  
        /**
 -       * Return the text to be displayed above the changes
 +       * Set the text to be displayed above the changes
         *
         * @param FormOptions $opts
 -       * @return string XHTML
 +       * @param int $numRows Number of rows in the result to show after this header
         */
 -      public function doHeader( $opts ) {
 +      public function doHeader( $opts, $numRows ) {
                global $wgScript;
  
                $this->setTopText( $opts );
  
                $panel = array();
                $panel[] = self::makeLegend( $this->getContext() );
 -              $panel[] = $this->optionsPanel( $defaults, $nondefaults );
 +              $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
                $panel[] = '<hr />';
  
                $extraOpts = $this->getExtraOptions( $opts );
         *
         * @param array $defaults
         * @param array $nondefaults
 +       * @param int $numRows Number of rows in the result to show after this header
         * @return string
         */
 -      function optionsPanel( $defaults, $nondefaults ) {
 +      function optionsPanel( $defaults, $nondefaults, $numRows ) {
                global $wgRCLinkLimits, $wgRCLinkDays;
  
                $options = $nondefaults + $defaults;
                $lang = $this->getLanguage();
                $user = $this->getUser();
                if ( $options['from'] ) {
 -                      $note .= $this->msg( 'rcnotefrom' )->numParams( $options['limit'] )->params(
 -                              $lang->userTimeAndDate( $options['from'], $user ),
 -                              $lang->userDate( $options['from'], $user ),
 -                              $lang->userTime( $options['from'], $user ) )->parse() . '<br />';
 +                      $note .= $this->msg( 'rcnotefrom' )
 +                              ->numParams( $options['limit'] )
 +                              ->params(
 +                                      $lang->userTimeAndDate( $options['from'], $user ),
 +                                      $lang->userDate( $options['from'], $user ),
 +                                      $lang->userTime( $options['from'], $user )
 +                              )
 +                              ->numParams( $numRows )
 +                              ->parse() . '<br />';
                }
  
                # Sort data for display and make sure it's unique after we've added user data.
@@@ -83,7 -83,7 +83,7 @@@ class SpecialWatchlist extends ChangesL
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
 -       * @param integer $limit Maximum number of results to return
 +       * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
                // the necessary rights.
                if ( !$user->isAllowed( 'deletedhistory' ) ) {
                        $bitmask = LogPage::DELETED_ACTION;
 -              } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
 +              } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
                        $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
                } else {
                        $bitmask = 0;
                        ''
                );
  
-               wfRunHooks( 'SpecialWatchlistQuery',
-                       array( &$conds, &$tables, &$join_conds, &$fields, $opts ),
-                       '1.23' );
+               $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
  
                return $dbr->select(
                        $tables,
                );
        }
  
+       protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) {
+               return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
+                       && wfRunHooks(
+                               'SpecialWatchlistQuery',
+                               array( &$conds, &$tables, &$join_conds, &$fields, $opts ),
+                               '1.23'
+                       );
+       }
        /**
         * Return a DatabaseBase object for reading
         *
        }
  
        /**
 -       * Return the text to be displayed above the changes
 +       * Set the text to be displayed above the changes
         *
         * @param FormOptions $opts
 -       * @return string XHTML
 +       * @param int $numRows Number of rows in the result to show after this header
         */
 -      public function doHeader( $opts ) {
 +      public function doHeader( $opts, $numRows ) {
                $user = $this->getUser();
  
                $this->getOutput()->addSubtitle(
                $wlInfo = '';
                if ( $opts['days'] > 0 ) {
                        $timestamp = wfTimestampNow();
 -                      $wlInfo = $this->msg( 'wlnote2' )->numParams( round( $opts['days'] * 24 ) )->params(
 +                      $wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
                                $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
                        )->parse() . "<br />\n";
                }