From 73664393f8da2ece208e43214c0020d8259e160a Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Fri, 2 Aug 2019 12:33:56 -0700 Subject: [PATCH] Pagers: Drop 'newbie' feature Change-Id: I14c4da7b107aa9c712bd81522021ae7ecaf2b790 --- includes/specials/SpecialContributions.php | 2 - includes/specials/pagers/ContribsPager.php | 92 +++++----------------- includes/specials/pagers/NewFilesPager.php | 14 ---- 3 files changed, 20 insertions(+), 88 deletions(-) diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index f1843ead93..9d5f430b3c 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -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'], diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index 1b0c59ab25..d62951cb7e 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -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 = ' ' . $lang->getDirMark() . Linker::userLink( $rev->getUser(), $rev->getUserText() ); diff --git a/includes/specials/pagers/NewFilesPager.php b/includes/specials/pagers/NewFilesPager.php index 57db8b3f5f..2cb2b4aaad 100644 --- a/includes/specials/pagers/NewFilesPager.php +++ b/includes/specials/pagers/NewFilesPager.php @@ -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() -- 2.20.1