X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FContribsPager.php;h=d62951cb7ea38ef9ffb9a2a97a06bd38d2bca0b9;hb=b4675c6125736c11b5a4c14c25a2bfaf41102264;hp=d82ba535a6c9a7833b3656d23f80f051076791b9;hpb=447574ceb746c2f4026a8bf77632bdc4604314bb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index d82ba535a6..d62951cb7e 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -24,6 +24,7 @@ * @ingroup Pager */ use MediaWiki\MediaWikiServices; +use MediaWiki\Storage\RevisionRecord; use Wikimedia\Rdbms\IResultWrapper; use Wikimedia\Rdbms\FakeResultWrapper; use Wikimedia\Rdbms\IDatabase; @@ -40,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 */ @@ -103,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; @@ -248,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 ) { @@ -278,51 +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 = User::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'; } } @@ -347,10 +311,16 @@ class ContribsPager extends RangeChronologicalPager { // Paranoia: avoid brute force searches (T19342) if ( !$user->isAllowed( 'deletedhistory' ) ) { - $queryInfo['conds'][] = $this->mDb->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0'; - } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) { - $queryInfo['conds'][] = $this->mDb->bitAnd( 'rev_deleted', Revision::SUPPRESSED_USER ) . - ' != ' . Revision::SUPPRESSED_USER; + $queryInfo['conds'][] = $this->mDb->bitAnd( + 'rev_deleted', RevisionRecord::DELETED_USER + ) . ' = 0'; + } elseif ( !MediaWikiServices::getInstance() + ->getPermissionManager() + ->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' ) + ) { + $queryInfo['conds'][] = $this->mDb->bitAnd( + 'rev_deleted', RevisionRecord::SUPPRESSED_USER + ) . ' != ' . RevisionRecord::SUPPRESSED_USER; } // $this->getIndexField() must be in the result rows, as reallyDoQuery() tries to access it. @@ -469,13 +439,6 @@ class ContribsPager extends RangeChronologicalPager { return $this->tagFilter; } - /** - * @return string - */ - public function getContribs() { - return $this->contribs; - } - /** * @return string */ @@ -535,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 ); } @@ -612,7 +572,7 @@ class ContribsPager extends RangeChronologicalPager { $classes = []; $attribs = []; - $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $linkRenderer = $this->getLinkRenderer(); $page = null; // Create a title for the revision if possible @@ -642,11 +602,12 @@ class ContribsPager extends RangeChronologicalPager { && $page->quickUserCan( 'edit', $user ) ) { $this->preventClickjacking(); - $topmarktext .= ' ' . Linker::generateRollback( $rev, $this->getContext() ); + $topmarktext .= ' ' . Linker::generateRollback( $rev, $this->getContext(), + [ 'noBrackets' ] ); } } # Is there a visible previous revision? - if ( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) { + if ( $rev->userCan( RevisionRecord::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) { $difftext = $linkRenderer->makeKnownLink( $page, new HtmlArmor( $this->messages['diff'] ), @@ -692,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( Revision::DELETED_USER ) ) - || $this->isQueryableRange( $this->target ) ) { + if ( $this->isQueryableRange( $this->target ) ) { $userlink = ' ' . $lang->getDirMark() . Linker::userLink( $rev->getUser(), $rev->getUserText() ); @@ -756,7 +714,7 @@ class ContribsPager extends RangeChronologicalPager { ]; # Denote if username is redacted for this edit - if ( $rev->isDeleted( Revision::DELETED_USER ) ) { + if ( $rev->isDeleted( RevisionRecord::DELETED_USER ) ) { $templateParams['rev-deleted-user-contribs'] = $this->msg( 'rev-deleted-user-contribs' )->escaped(); }