/** @var bool */
private $actionRestrictionsEnforced = false;
+ /** @var array */
+ private $mConds;
+
+ /** @var string */
+ private $mTagFilter;
+
/** @var LogEventsList */
public $mLogEventsList;
$this->mLogEventsList = $list;
$this->limitType( $types ); // also excludes hidden types
+ $this->limitLogId( $logId );
+ $this->limitFilterTypes();
$this->limitPerformer( $performer );
$this->limitTitle( $title, $pattern );
$this->limitAction( $action );
$this->getDateCond( $year, $month, $day );
$this->mTagFilter = $tagFilter;
- $this->limitLogId( $logId );
$this->mDb = wfGetDB( DB_REPLICA, 'logpager' );
}
return $query;
}
- // Call ONLY after calling $this->limitType() already!
+ private function limitFilterTypes() {
+ if ( $this->hasEqualsClause( 'log_id' ) ) { // T220834
+ return;
+ }
+ $filterTypes = $this->getFilterParams();
+ foreach ( $filterTypes as $type => $hide ) {
+ if ( $hide ) {
+ $this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );
+ }
+ }
+ }
+
public function getFilterParams() {
global $wgFilterLogTypes;
$filters = [];
}
$filters[$type] = $hide;
- if ( $hide ) {
- $this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );
- }
}
return $filters;
$needReindex = false;
foreach ( $types as $type ) {
if ( isset( $wgLogRestrictions[$type] )
- && !$user->isAllowed( $wgLogRestrictions[$type] )
+ && !MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $user, $wgLogRestrictions[$type] )
) {
$needReindex = true;
$types = array_diff( $types, [ $type ] );
if ( !$this->mTagFilter && !array_key_exists( 'ls_field', $this->mConds ) ) {
$options[] = 'STRAIGHT_JOIN';
}
+ if ( $this->performer !== '' ) {
+ // T223151: MariaDB's optimizer, at least 10.1, likes to choose a wildly bad plan for
+ // some reason for this code path. Tell it not to use the wrong index it wants to pick.
+ $options['IGNORE INDEX'] = [ 'logging' => [ 'times' ] ];
+ }
$info = [
'tables' => $tables,
}
$this->actionRestrictionsEnforced = true;
$user = $this->getUser();
- if ( !$user->isAllowed( 'deletedhistory' ) ) {
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ if ( !$permissionManager->userHasRight( $user, 'deletedhistory' ) ) {
$this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_ACTION ) . ' = 0';
- } elseif ( !MediaWikiServices::getInstance()
- ->getPermissionManager()
- ->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' )
- ) {
+ } elseif ( !$permissionManager->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' ) ) {
$this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_ACTION ) .
' != ' . LogPage::SUPPRESSED_USER;
}
}
$this->performerRestrictionsEnforced = true;
$user = $this->getUser();
- if ( !$user->isAllowed( 'deletedhistory' ) ) {
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+ if ( !$permissionManager->userHasRight( $user, 'deletedhistory' ) ) {
$this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::DELETED_USER ) . ' = 0';
- } elseif ( !MediaWikiServices::getInstance()
- ->getPermissionManager()
- ->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' )
- ) {
+ } elseif ( !$permissionManager->userHasAnyRight( $user, 'suppressrevision', 'viewsuppressed' ) ) {
$this->mConds[] = $this->mDb->bitAnd( 'log_deleted', LogPage::SUPPRESSED_USER ) .
' != ' . LogPage::SUPPRESSED_ACTION;
}