/** @var string|Title Events limited to those about Title when set */
private $title = '';
- /** @var string */
- private $pattern = '';
+ /** @var bool */
+ private $pattern = false;
/** @var string */
private $typeCGI = '';
* @param string|array $types Log types to show
* @param string $performer The user who made the log entries
* @param string|Title $title The page title the log entries are for
- * @param string $pattern Do a prefix search rather than an exact title match
+ * @param bool $pattern Do a prefix search rather than an exact title match
* @param array $conds Extra conditions for the query
* @param int|bool $year The year to start from. Default: false
* @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 = ''
+ $pattern = false, $conds = [], $year = false, $month = false, $tagFilter = '',
+ $action = '', $logId = false
) {
parent::__construct( $list->getContext() );
$this->mConds = $conds;
$this->limitAction( $action );
$this->getDateCond( $year, $month );
$this->mTagFilter = $tagFilter;
+ $this->limitLogId( $logId );
$this->mDb = wfGetDB( DB_REPLICA, 'logpager' );
}
// 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;
* (For the block and rights logs, this is a user page.)
*
* @param string|Title $page Title name
- * @param string $pattern
+ * @param bool $pattern
* @return void
*/
private function limitTitle( $page, $pattern ) {
}
}
+ /**
+ * 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.
return $this->title;
}
+ /**
+ * @return bool
+ */
public function getPattern() {
return $this->pattern;
}
$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;
}
}
$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;
}
}