Merge "Mark constructors of IndexPager subclasses as public"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 1 Jan 2019 14:29:49 +0000 (14:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 1 Jan 2019 14:29:49 +0000 (14:29 +0000)
1  2 
includes/actions/HistoryAction.php
includes/specials/pagers/ActiveUsersPager.php
includes/specials/pagers/AllMessagesTablePager.php
includes/specials/pagers/BlockListPager.php
includes/specials/pagers/DeletedContribsPager.php
includes/specials/pagers/ImageListPager.php
includes/specials/pagers/MergeHistoryPager.php
includes/specials/pagers/NewFilesPager.php
includes/specials/pagers/NewPagesPager.php
includes/specials/pagers/ProtectedTitlesPager.php
includes/specials/pagers/UsersPager.php

@@@ -415,7 -415,13 +415,13 @@@ class HistoryPager extends ReverseChron
         * @param string $tagFilter
         * @param array $conds
         */
-       function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
+       public function __construct(
+               HistoryAction $historyPage,
+               $year = '',
+               $month = '',
+               $tagFilter = '',
+               array $conds = []
+       ) {
                parent::__construct( $historyPage->getContext() );
                $this->historyPage = $historyPage;
                $this->tagFilter = $tagFilter;
                return $s;
        }
  
 -      function doBatchLookups() {
 +      protected function doBatchLookups() {
                if ( !Hooks::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult ] ) ) {
                        return;
                }
         *
         * @return string HTML output
         */
 -      function getStartBody() {
 +      protected function getStartBody() {
                $this->lastRow = false;
                $this->counter = 1;
                $this->oldIdChecked = 0;
                return $element;
        }
  
 -      function getEndBody() {
 +      protected function getEndBody() {
                if ( $this->lastRow ) {
                        $latest = $this->counter == 1 && $this->mIsFirst;
                        $firstInList = $this->counter == 1;
@@@ -47,7 -47,7 +47,7 @@@ class ActiveUsersPager extends UsersPag
         * @param IContextSource|null $context
         * @param FormOptions $opts
         */
-       function __construct( IContextSource $context = null, FormOptions $opts ) {
+       public function __construct( IContextSource $context = null, FormOptions $opts ) {
                parent::__construct( $context );
  
                $this->RCMaxAge = $this->getConfig()->get( 'ActiveUserDays' );
                ];
        }
  
 -      function doBatchLookups() {
 +      protected function doBatchLookups() {
                parent::doBatchLookups();
  
                $uids = [];
                // is done in two queries to avoid huge quicksorts and to make COUNT(*) correct.
                $dbr = $this->getDatabase();
                $res = $dbr->select( 'ipblocks',
 -                      [ 'ipb_user', 'MAX(ipb_deleted) AS block_status' ],
 +                      [ 'ipb_user', 'MAX(ipb_deleted) AS deleted, MAX(ipb_sitewide) AS sitewide' ],
                        [ 'ipb_user' => $uids ],
                        __METHOD__,
                        [ 'GROUP BY' => [ 'ipb_user' ] ]
                );
                $this->blockStatusByUid = [];
                foreach ( $res as $row ) {
 -                      $this->blockStatusByUid[$row->ipb_user] = $row->block_status; // 0 or 1
 +                      $this->blockStatusByUid[$row->ipb_user] = [
 +                              'deleted' => $row->deleted,
 +                              'sitewide' => $row->sitewide,
 +                      ];
                }
                $this->mResult->seek( 0 );
        }
  
                $item = $lang->specialList( $ulinks, $groups );
  
 +              // If there is a block, 'deleted' and 'sitewide' are both set on
 +              // $this->blockStatusByUid[$row->user_id].
 +              $blocked = '';
                $isBlocked = isset( $this->blockStatusByUid[$row->user_id] );
 -              if ( $isBlocked && $this->blockStatusByUid[$row->user_id] == 1 ) {
 -                      $item = "<span class=\"deleted\">$item</span>";
 +              if ( $isBlocked ) {
 +                      if ( $this->blockStatusByUid[$row->user_id]['deleted'] == 1 ) {
 +                              $item = "<span class=\"deleted\">$item</span>";
 +                      }
 +                      if ( $this->blockStatusByUid[$row->user_id]['sitewide'] == 1 ) {
 +                              $blocked = ' ' . $this->msg( 'listusers-blocked', $userName )->escaped();
 +                      }
                }
                $count = $this->msg( 'activeusers-count' )->numParams( $row->recentedits )
                        ->params( $userName )->numParams( $this->RCMaxAge )->escaped();
 -              $blocked = $isBlocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
  
                return Html::rawElement( 'li', [], "{$item} [{$count}]{$blocked}" );
        }
@@@ -44,7 -44,7 +44,7 @@@ class AllMessagesTablePager extends Tab
         */
        public $custom;
  
-       function __construct( $page, $conds, Language $langObj = null ) {
+       public function __construct( $page, $conds, Language $langObj = null ) {
                parent::__construct( $page->getContext() );
                $this->mIndexField = 'am_title';
                $this->mPage = $page;
                return $result;
        }
  
 -      function getStartBody() {
 +      protected function getStartBody() {
                $tableClass = $this->getTableClass();
                return Xml::openElement( 'table', [
                        'class' => "mw-datatable $tableClass",
                                <th>" .
                $this->msg( 'allmessagescurrent' )->escaped() .
                "</th>
 -                      </tr></thead><tbody>\n";
 +                      </tr></thead>\n";
 +      }
 +
 +      function getEndBody() {
 +              return Html::closeElement( 'table' );
        }
  
        function formatValue( $field, $value ) {
                return '';
        }
  
 +      /** @return string HTML */
        function formatRow( $row ) {
                // Do all the normal stuff
                $s = parent::formatRow( $row );
  
                // But if there's a customised message, add that too.
                if ( $row->am_customised ) {
 -                      $s .= Xml::openElement( 'tr', $this->getRowAttrs( $row, true ) );
 +                      $s .= Html::openElement( 'tr', $this->getRowAttrs( $row, true ) );
                        $formatted = strval( $this->formatValue( 'am_actual', $row->am_actual ) );
  
                        if ( $formatted === '' ) {
                                $formatted = "\u{00A0}";
                        }
  
 -                      $s .= Xml::tags( 'td', $this->getCellAttrs( 'am_actual', $row->am_actual ), $formatted )
 -                              . "</tr>\n";
 +                      $s .= Html::element( 'td', $this->getCellAttrs( 'am_actual', $row->am_actual ), $formatted )
 +                              . Html::closeElement( 'tr' );
                }
  
 -              return $s;
 +              return Html::rawElement( 'tbody', [], $s );
        }
  
 -      function getRowAttrs( $row, $isSecond = false ) {
 -              $arr = [];
 -
 -              if ( $row->am_customised ) {
 -                      $arr['class'] = 'allmessages-customised';
 -              }
 -
 -              if ( !$isSecond ) {
 -                      $arr['id'] = Sanitizer::escapeIdForAttribute(
 -                              'msg_' . $this->getLanguage()->lcfirst( $row->am_title )
 -                      );
 -              }
 -
 -              return $arr;
 +      function getRowAttrs( $row ) {
 +              return [];
        }
  
 +      /** @return array HTML attributes */
        function getCellAttrs( $field, $value ) {
 -              if ( $this->mCurrentRow->am_customised && $field === 'am_title' ) {
 -                      return [ 'rowspan' => '2', 'class' => $field ];
 -              } elseif ( $field === 'am_title' ) {
 -                      return [ 'class' => $field ];
 +              $attr = [];
 +              if ( $field === 'am_title' ) {
 +                      if ( $this->mCurrentRow->am_customised ) {
 +                              $attr += [ 'rowspan' => '2' ];
 +                      }
                } else {
 -                      return [
 +                      $attr += [
                                'lang' => $this->lang->getHtmlCode(),
                                'dir' => $this->lang->getDir(),
 -                              'class' => $field
                        ];
 +                      if ( $this->mCurrentRow->am_customised ) {
 +                              // CSS class: am_default, am_actual
 +                              $attr += [ 'class' => $field ];
 +                      }
                }
 +              return $attr;
        }
  
        // This is not actually used, as getStartBody is overridden above
@@@ -43,7 -43,7 +43,7 @@@ class BlockListPager extends TablePage
         * @param SpecialPage $page
         * @param array $conds
         */
-       function __construct( $page, $conds ) {
+       public function __construct( $page, $conds ) {
                $this->page = $page;
                $this->conds = $conds;
                $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
                                                'ul',
                                                [],
                                                implode( '', array_map( function ( $prop ) {
 -                                                      return HTML::rawElement(
 +                                                      return Html::rawElement(
                                                                'li',
                                                                [],
                                                                $prop
                                continue;
                        }
  
 -                      $items[] = HTML::rawElement(
 +                      $items[] = Html::rawElement(
                                'li',
                                [],
                                Linker::link( $restriction->getTitle() )
@@@ -40,7 -40,7 +40,7 @@@ class DeletedContribsPager extends Inde
         */
        protected $mNavigationBar;
  
-       function __construct( IContextSource $context, $target, $namespace = false ) {
+       public function __construct( IContextSource $context, $target, $namespace = false ) {
                parent::__construct( $context );
                $msgs = [ 'deletionlog', 'undeleteviewlink', 'diff' ];
                foreach ( $msgs as $msg ) {
                return 'ar_timestamp';
        }
  
 -      function getStartBody() {
 +      protected function getStartBody() {
                return "<ul>\n";
        }
  
 -      function getEndBody() {
 +      protected function getEndBody() {
                return "</ul>\n";
        }
  
@@@ -50,7 -50,7 +50,7 @@@ class ImageListPager extends TablePage
  
        protected $mTableName = 'image';
  
-       function __construct( IContextSource $context, $userName = null, $search = '',
+       public function __construct( IContextSource $context, $userName = null, $search = '',
                $including = false, $showAll = false
        ) {
                $this->setContext( $context );
                $conds = [];
  
                if ( !is_null( $this->mUserName ) ) {
 -                      $conds[$prefix . '_user_text'] = $this->mUserName;
 +                      // getQueryInfoReal() should have handled the tables and joins.
 +                      $dbr = wfGetDB( DB_REPLICA );
 +                      $actorWhere = ActorMigration::newMigration()->getWhere(
 +                              $dbr,
 +                              $prefix . '_user',
 +                              User::newFromName( $this->mUserName, false ),
 +                              // oldimage doesn't have an index on oi_user, while image does. Set $useId accordingly.
 +                              $prefix === 'img'
 +                      );
 +                      $conds[] = $actorWhere['conds'];
                }
  
                if ( $this->mSearch !== '' ) {
                }
        }
  
 -      function doBatchLookups() {
 +      protected function doBatchLookups() {
                $userIds = [];
                $this->mResult->seek( 0 );
                foreach ( $this->mResult as $row ) {
@@@ -30,7 -30,7 +30,7 @@@ class MergeHistoryPager extends Reverse
        /** @var array */
        public $mConds;
  
-       function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
+       public function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
                $this->mForm = $form;
                $this->mConds = $conds;
                $this->title = $source;
@@@ -48,7 -48,7 +48,7 @@@
                parent::__construct( $form->getContext() );
        }
  
 -      function getStartBody() {
 +      protected function getStartBody() {
                # Do a link batch query
                $this->mResult->seek( 0 );
                $batch = new LinkBatch();
@@@ -40,7 -40,7 +40,7 @@@ class NewFilesPager extends RangeChrono
         * @param IContextSource $context
         * @param FormOptions $opts
         */
-       function __construct( IContextSource $context, FormOptions $opts ) {
+       public function __construct( IContextSource $context, FormOptions $opts ) {
                parent::__construct( $context );
  
                $this->opts = $opts;
                return 'img_timestamp';
        }
  
 -      function getStartBody() {
 +      protected function getStartBody() {
                if ( !$this->gallery ) {
                        // Note that null for mode is taken to mean use default.
                        $mode = $this->getRequest()->getVal( 'gallerymode', null );
                return '';
        }
  
 -      function getEndBody() {
 +      protected function getEndBody() {
                return $this->gallery->toHTML();
        }
  
@@@ -32,7 -32,7 +32,7 @@@ class NewPagesPager extends ReverseChro
         */
        protected $mForm;
  
-       function __construct( $form, FormOptions $opts ) {
+       public function __construct( $form, FormOptions $opts ) {
                parent::__construct( $form->getContext() );
                $this->mForm = $form;
                $this->opts = $opts;
@@@ -59,6 -59,8 +59,6 @@@
                        }
                }
  
 -              $rcIndexes = [];
 -
                if ( $namespace !== false ) {
                        if ( $this->opts->getValue( 'invert' ) ) {
                                $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace );
                Hooks::run( 'SpecialNewpagesConditions',
                        [ &$pager, $this->opts, &$conds, &$tables, &$fields, &$join_conds ] );
  
 -              $options = [];
 -
 -              if ( $rcIndexes ) {
 -                      $options = [ 'USE INDEX' => [ 'recentchanges' => $rcIndexes ] ];
 -              }
 -
                $info = [
                        'tables' => $tables,
                        'fields' => $fields,
                        'conds' => $conds,
 -                      'options' => $options,
 +                      'options' => [],
                        'join_conds' => $join_conds
                ];
  
                return $this->mForm->formatRow( $row );
        }
  
 -      function getStartBody() {
 +      protected function getStartBody() {
                # Do a batch existence check on pages
                $linkBatch = new LinkBatch();
                foreach ( $this->mResult as $row ) {
                return '<ul>';
        }
  
 -      function getEndBody() {
 +      protected function getEndBody() {
                return '</ul>';
        }
  }
@@@ -26,7 -26,7 +26,7 @@@ class ProtectedTitlesPager extends Alph
  
        public $mForm, $mConds;
  
-       function __construct( $form, $conds, $type, $level, $namespace,
+       public function __construct( $form, $conds, $type, $level, $namespace,
                $sizetype = '', $size = 0
        ) {
                $this->mForm = $form;
@@@ -37,7 -37,7 +37,7 @@@
                parent::__construct( $form->getContext() );
        }
  
 -      function getStartBody() {
 +      protected function getStartBody() {
                # Do a link batch query
                $this->mResult->seek( 0 );
                $lb = new LinkBatch;
@@@ -43,7 -43,7 +43,7 @@@ class UsersPager extends AlphabeticPage
         * @param bool|null $including Whether this page is being transcluded in
         * another page
         */
-       function __construct( IContextSource $context = null, $par = null, $including = null ) {
+       public function __construct( IContextSource $context = null, $par = null, $including = null ) {
                if ( $context ) {
                        $this->setContext( $context );
                }
                                'user_id' => $this->creationSort ? 'user_id' : 'MAX(user_id)',
                                'edits' => 'MAX(user_editcount)',
                                'creation' => 'MIN(user_registration)',
 -                              'ipb_deleted' => 'MAX(ipb_deleted)' // block/hide status
 +                              'ipb_deleted' => 'MAX(ipb_deleted)', // block/hide status
 +                              'ipb_sitewide' => 'MAX(ipb_sitewide)'
                        ],
                        'options' => $options,
                        'join_conds' => [
                        $created = $this->msg( 'usercreated', $d, $t, $row->user_name )->escaped();
                        $created = ' ' . $this->msg( 'parentheses' )->rawParams( $created )->escaped();
                }
 -              $blocked = !is_null( $row->ipb_deleted ) ?
 +
 +              $blocked = !is_null( $row->ipb_deleted ) && $row->ipb_sitewide === '1' ?
                        ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() :
                        '';
  
                return Html::rawElement( 'li', [], "{$item}{$edits}{$created}{$blocked}" );
        }
  
 -      function doBatchLookups() {
 +      protected function doBatchLookups() {
                $batch = new LinkBatch();
                $userIds = [];
                # Give some pointers to make user links