X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAllDeletedRevisions.php;h=be1297799412be4e7a9457330f7e7f45939032bc;hb=bb8c060128a79532e1b6885fb3ebd6174d3f4d4d;hp=32d081e4390356d97af43a404e15a306848c2df7;hpb=c2adecb31b16a36efdb509a575533c7f103a0576;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryAllDeletedRevisions.php b/includes/api/ApiQueryAllDeletedRevisions.php index 32d081e439..be12977994 100644 --- a/includes/api/ApiQueryAllDeletedRevisions.php +++ b/includes/api/ApiQueryAllDeletedRevisions.php @@ -136,16 +136,11 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase { } if ( $this->fetchContent ) { - // Modern MediaWiki has the content for deleted revs in the 'text' - // table using fields old_text and old_flags. But revisions deleted - // pre-1.5 store the content in the 'archive' table directly using - // fields ar_text and ar_flags, and no corresponding 'text' row. So - // we have to LEFT JOIN and fetch all four fields. $this->addTables( 'text' ); $this->addJoinConds( [ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ] ); - $this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] ); + $this->addFields( [ 'old_text', 'old_flags' ] ); // This also means stricter restrictions $this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] ); @@ -224,10 +219,19 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase { } 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'] ) ) {