X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Flogging%2FLogPager.php;h=c047e96ea364ecdf2af90b4cfabda345c9ecd8fc;hp=5404f35fced74064f932da7c8d031de558a3f5d9;hb=def02ea00c02fcd6e7548683e9cbe9141f1a26e6;hpb=d84c3dde5af90c5c3497d18e427a5c2a38ac6ca8 diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 5404f35fce..c047e96ea3 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -65,10 +65,11 @@ class LogPager extends ReverseChronologicalPager { * @param int|bool $month The month to start from. Default: false * @param string $tagFilter Tag * @param string $action Specific action (subtype) requested + * @param int $logId Log entry ID, to limit to a single log entry. */ public function __construct( $list, $types = [], $performer = '', $title = '', $pattern = '', $conds = [], $year = false, $month = false, $tagFilter = '', - $action = '' + $action = '', $logId = false ) { parent::__construct( $list->getContext() ); $this->mConds = $conds; @@ -81,6 +82,7 @@ class LogPager extends ReverseChronologicalPager { $this->limitAction( $action ); $this->getDateCond( $year, $month ); $this->mTagFilter = $tagFilter; + $this->limitLogId( $logId ); $this->mDb = wfGetDB( DB_REPLICA, 'logpager' ); } @@ -176,13 +178,12 @@ class LogPager extends ReverseChronologicalPager { // Normalize username first so that non-existent users used // in maintenance scripts work $name = $usertitle->getText(); - /* Fetch userid at first, if known, provides awesome query plan afterwards */ - $userid = User::idFromName( $name ); - if ( !$userid ) { - $this->mConds['log_user_text'] = IP::sanitizeIP( $name ); - } else { - $this->mConds['log_user'] = $userid; - } + + // Assume no joins required for log_user + $this->mConds[] = ActorMigration::newMigration()->getWhere( + wfGetDB( DB_REPLICA ), 'log_user', User::newFromName( $name, false ) + )['conds']; + $this->enforcePerformerRestrictions(); $this->performer = $name; @@ -279,6 +280,17 @@ class LogPager extends ReverseChronologicalPager { } } + /** + * Limit to the (single) specified log ID. + * @param int $logId The log entry ID. + */ + protected function limitLogId( $logId ) { + if ( !$logId ) { + return; + } + $this->mConds['log_id'] = $logId; + } + /** * Constructs the most part of the query. Extra conditions are sprinkled in * all over this class. @@ -423,9 +435,9 @@ class LogPager extends ReverseChronologicalPager { $this->actionRestrictionsEnforced = true; $user = $this->getUser(); if ( !$user->isAllowed( 'deletedhistory' ) ) { - $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0'; + $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0'; } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) { - $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) . + $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION ) . ' != ' . LogPage::SUPPRESSED_USER; } } @@ -441,9 +453,9 @@ class LogPager extends ReverseChronologicalPager { $this->performerRestrictionsEnforced = true; $user = $this->getUser(); if ( !$user->isAllowed( 'deletedhistory' ) ) { - $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0'; + $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0'; } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) { - $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION ) . + $this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) . ' != ' . LogPage::SUPPRESSED_ACTION; } }