X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryDeletedrevs.php;h=2d5074178ef6f1543c366d98b22ceefa5128572a;hp=6e6757ecd11521d8f5db51f077528f6965f54f20;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hpb=c2adecb31b16a36efdb509a575533c7f103a0576 diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 6e6757ecd1..2d5074178e 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -110,8 +110,12 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $this->addFieldsIf( 'ar_parent_id', $fld_parentid ); $this->addFieldsIf( 'ar_rev_id', $fld_revid ); - $this->addFieldsIf( 'ar_user_text', $fld_user ); - $this->addFieldsIf( 'ar_user', $fld_userid ); + if ( $fld_user || $fld_userid ) { + $actorQuery = ActorMigration::newMigration()->getJoin( 'ar_user' ); + $this->addTables( $actorQuery['tables'] ); + $this->addFields( $actorQuery['fields'] ); + $this->addJoinConds( $actorQuery['joins'] ); + } $this->addFieldsIf( 'ar_minor_edit', $fld_minor ); $this->addFieldsIf( 'ar_len', $fld_len ); $this->addFieldsIf( 'ar_sha1', $fld_sha1 ); @@ -199,10 +203,19 @@ class ApiQueryDeletedrevs extends ApiQueryBase { } if ( !is_null( $params['user'] ) ) { - $this->addWhereFld( 'ar_user_text', $params['user'] ); + // Don't query by user ID here, it might be able to use the ar_usertext_timestamp index. + $actorQuery = ActorMigration::newMigration() + ->getWhere( $db, 'ar_user', User::newFromName( $params['user'], false ), false ); + $this->addTables( $actorQuery['tables'] ); + $this->addJoinConds( $actorQuery['joins'] ); + $this->addWhere( $actorQuery['conds'] ); } elseif ( !is_null( $params['excludeuser'] ) ) { - $this->addWhere( 'ar_user_text != ' . - $db->addQuotes( $params['excludeuser'] ) ); + // Here there's no chance of using ar_usertext_timestamp. + $actorQuery = ActorMigration::newMigration() + ->getWhere( $db, 'ar_user', User::newFromName( $params['excludeuser'], false ) ); + $this->addTables( $actorQuery['tables'] ); + $this->addJoinConds( $actorQuery['joins'] ); + $this->addWhere( 'NOT(' . $actorQuery['conds'] . ')' ); } if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) { @@ -251,10 +264,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase { } $this->addOption( 'LIMIT', $limit + 1 ); - $this->addOption( - 'USE INDEX', - [ 'archive' => ( $mode == 'user' ? 'ar_usertext_timestamp' : 'name_title_timestamp' ) ] - ); if ( $mode == 'all' ) { if ( $params['unique'] ) { // @todo Does this work on non-MySQL?