Pagers: Drop 'newbie' feature
authorJames D. Forrester <jforrester@wikimedia.org>
Fri, 2 Aug 2019 19:33:56 +0000 (12:33 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 28 Aug 2019 18:09:19 +0000 (11:09 -0700)
Change-Id: I14c4da7b107aa9c712bd81522021ae7ecaf2b790

includes/specials/SpecialContributions.php
includes/specials/pagers/ContribsPager.php
includes/specials/pagers/NewFilesPager.php

index f1843ea..9d5f430 100644 (file)
@@ -203,8 +203,6 @@ class SpecialContributions extends IncludableSpecialPage {
                        }
                        $pager = new ContribsPager( $this->getContext(), [
                                'target' => $target,
-                               // Temporary, until newbie feature is fully removed from ContribsPager
-                               'contribs' => 'user',
                                'namespace' => $this->opts['namespace'],
                                'tagfilter' => $this->opts['tagfilter'],
                                'start' => $this->opts['start'],
index 1b0c59a..d62951c 100644 (file)
@@ -41,12 +41,6 @@ class ContribsPager extends RangeChronologicalPager {
         */
        private $target;
 
-       /**
-        * @var string Set to "newbie" to list contributions from the most recent 1% registered users.
-        *  $this->target is ignored then. Defaults to "users".
-        */
-       private $contribs;
-
        /**
         * @var string|int A single namespace number, or an empty string for all namespaces
         */
@@ -104,11 +98,10 @@ class ContribsPager extends RangeChronologicalPager {
        private $templateParser;
 
        public function __construct( IContextSource $context, array $options ) {
-               // Set ->target and ->contribs before calling parent::__construct() so
+               // Set ->target before calling parent::__construct() so
                // parent can call $this->getIndexField() and get the right result. Set
                // the rest too just to keep things simple.
                $this->target = $options['target'] ?? '';
-               $this->contribs = $options['contribs'] ?? 'users';
                $this->namespace = $options['namespace'] ?? '';
                $this->tagFilter = $options['tagfilter'] ?? false;
                $this->nsInvert = $options['nsInvert'] ?? false;
@@ -249,10 +242,6 @@ class ContribsPager extends RangeChronologicalPager {
         * @return string
         */
        private function getTargetTable() {
-               if ( $this->contribs == 'newbie' ) {
-                       return 'revision';
-               }
-
                $user = User::newFromName( $this->target, false );
                $ipRangeConds = $user->isAnon() ? $this->getIpRangeConds( $this->mDb, $this->target ) : null;
                if ( $ipRangeConds ) {
@@ -279,53 +268,25 @@ class ContribsPager extends RangeChronologicalPager {
                ];
 
                // WARNING: Keep this in sync with getTargetTable()!
-
-               if ( $this->contribs == 'newbie' ) {
-                       $max = $this->mDb->selectField( 'user', 'max(user_id)', '', __METHOD__ );
-                       $queryInfo['conds'][] = $revQuery['fields']['rev_user'] . ' >' . (int)( $max - $max / 100 );
-                       # ignore local groups with the bot right
-                       # @todo FIXME: Global groups may have 'bot' rights
-                       $groupsWithBotPermission = MediaWikiServices::getInstance()
-                               ->getPermissionManager()
-                               ->getGroupsWithPermission( 'bot' );
-                       if ( count( $groupsWithBotPermission ) ) {
-                               $queryInfo['tables'][] = 'user_groups';
-                               $queryInfo['conds'][] = 'ug_group IS NULL';
-                               $queryInfo['join_conds']['user_groups'] = [
-                                       'LEFT JOIN', [
-                                               'ug_user = ' . $revQuery['fields']['rev_user'],
-                                               'ug_group' => $groupsWithBotPermission,
-                                               'ug_expiry IS NULL OR ug_expiry >= ' .
-                                                       $this->mDb->addQuotes( $this->mDb->timestamp() )
-                                       ]
-                               ];
-                       }
-                       // (T140537) Disallow looking too far in the past for 'newbies' queries. If the user requested
-                       // a timestamp offset far in the past such that there are no edits by users with user_ids in
-                       // the range, we would end up scanning all revisions from that offset until start of time.
-                       $queryInfo['conds'][] = 'rev_timestamp > ' .
-                               $this->mDb->addQuotes( $this->mDb->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
+               $user = User::newFromName( $this->target, false );
+               $ipRangeConds = $user->isAnon() ? $this->getIpRangeConds( $this->mDb, $this->target ) : null;
+               if ( $ipRangeConds ) {
+                       $queryInfo['tables'][] = 'ip_changes';
+                       $queryInfo['join_conds']['ip_changes'] = [
+                               'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
+                       ];
+                       $queryInfo['conds'][] = $ipRangeConds;
                } else {
-                       $user = User::newFromName( $this->target, false );
-                       $ipRangeConds = $user->isAnon() ? $this->getIpRangeConds( $this->mDb, $this->target ) : null;
-                       if ( $ipRangeConds ) {
-                               $queryInfo['tables'][] = 'ip_changes';
-                               $queryInfo['join_conds']['ip_changes'] = [
-                                       'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
-                               ];
-                               $queryInfo['conds'][] = $ipRangeConds;
+                       // tables and joins are already handled by Revision::getQueryInfo()
+                       $conds = ActorMigration::newMigration()->getWhere( $this->mDb, 'rev_user', $user );
+                       $queryInfo['conds'][] = $conds['conds'];
+                       // Force the appropriate index to avoid bad query plans (T189026)
+                       if ( isset( $conds['orconds']['actor'] ) ) {
+                               // @todo: This will need changing when revision_actor_temp goes away
+                               $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
                        } else {
-                               // tables and joins are already handled by Revision::getQueryInfo()
-                               $conds = ActorMigration::newMigration()->getWhere( $this->mDb, 'rev_user', $user );
-                               $queryInfo['conds'][] = $conds['conds'];
-                               // Force the appropriate index to avoid bad query plans (T189026)
-                               if ( isset( $conds['orconds']['actor'] ) ) {
-                                       // @todo: This will need changing when revision_actor_temp goes away
-                                       $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
-                               } else {
-                                       $queryInfo['options']['USE INDEX']['revision'] =
-                                               isset( $conds['orconds']['userid'] ) ? 'user_timestamp' : 'usertext_timestamp';
-                               }
+                               $queryInfo['options']['USE INDEX']['revision'] =
+                                       isset( $conds['orconds']['userid'] ) ? 'user_timestamp' : 'usertext_timestamp';
                        }
                }
 
@@ -478,13 +439,6 @@ class ContribsPager extends RangeChronologicalPager {
                return $this->tagFilter;
        }
 
-       /**
-        * @return string
-        */
-       public function getContribs() {
-               return $this->contribs;
-       }
-
        /**
         * @return string
         */
@@ -544,10 +498,7 @@ class ContribsPager extends RangeChronologicalPager {
                        }
                        if ( isset( $row->rev_id ) ) {
                                $this->mParentLens[$row->rev_id] = $row->rev_len;
-                               if ( $this->contribs === 'newbie' ) { // multiple users
-                                       $batch->add( NS_USER, $row->user_name );
-                                       $batch->add( NS_USER_TALK, $row->user_name );
-                               } elseif ( $isIpRange ) {
+                               if ( $isIpRange ) {
                                        // If this is an IP range, batch the IP's talk page
                                        $batch->add( NS_USER_TALK, $row->rev_user_text );
                                }
@@ -702,12 +653,9 @@ class ContribsPager extends RangeChronologicalPager {
                        $comment = $lang->getDirMark() . Linker::revComment( $rev, false, true, false );
                        $d = ChangesList::revDateLink( $rev, $user, $lang, $page );
 
-                       # Show user names for /newbies as there may be different users.
-                       # Note that only unprivileged users have rows with hidden user names excluded.
                        # When querying for an IP range, we want to always show user and user talk links.
                        $userlink = '';
-                       if ( ( $this->contribs == 'newbie' && !$rev->isDeleted( RevisionRecord::DELETED_USER ) )
-                               || $this->isQueryableRange( $this->target ) ) {
+                       if ( $this->isQueryableRange( $this->target ) ) {
                                $userlink = ' <span class="mw-changeslist-separator"></span> '
                                        . $lang->getDirMark()
                                        . Linker::userLink( $rev->getUser(), $rev->getUserText() );
index 57db8b3..2cb2b4a 100644 (file)
@@ -72,20 +72,6 @@ class NewFilesPager extends RangeChronologicalPager {
                                ->getWhere( wfGetDB( DB_REPLICA ), 'img_user', User::newFromName( $user, false ) )['conds'];
                }
 
-               if ( $opts->getValue( 'newbies' ) ) {
-                       // newbie = most recent 1% of users
-                       $dbr = wfGetDB( DB_REPLICA );
-                       $max = $dbr->selectField( 'user', 'max(user_id)', '', __METHOD__ );
-                       $conds[] = $imgQuery['fields']['img_user'] . ' >' . (int)( $max - $max / 100 );
-
-                       // there's no point in looking for new user activity in a far past;
-                       // beyond a certain point, we'd just end up scanning the rest of the
-                       // table even though the users we're looking for didn't yet exist...
-                       // see T140537, (for ContribsPages, but similar to this)
-                       $conds[] = 'img_timestamp > ' .
-                               $dbr->addQuotes( $dbr->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
-               }
-
                if ( !$opts->getValue( 'showbots' ) ) {
                        $groupsWithBotPermission = MediaWikiServices::getInstance()
                                ->getPermissionManager()