X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryDeletedRevisions.php;h=c3af71bff845f54c50f13d0297ee487bb96e77f9;hb=afcd5b1771a6d755372cfe0081b7f413af62530d;hp=8e4752e8cfab76faf1dd8e7bd7541d46be48073e;hpb=00cc6ec3ba3de2bfb2873651ddaf06d29addfd55;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryDeletedRevisions.php b/includes/api/ApiQueryDeletedRevisions.php index 8e4752e8cf..c3af71bff8 100644 --- a/includes/api/ApiQueryDeletedRevisions.php +++ b/includes/api/ApiQueryDeletedRevisions.php @@ -1,7 +1,5 @@ extractRequestParams( false ); $db = $this->getDB(); + $revisionStore = MediaWikiServices::getInstance()->getRevisionStore(); $this->requireMaxOneParameter( $params, 'user', 'excludeuser' ); - $this->addTables( 'archive' ); if ( $resultPageSet === null ) { $this->parseParameters( $params ); - $this->addFields( Revision::selectArchiveFields() ); + $arQuery = $revisionStore->getArchiveQueryInfo(); + $this->addTables( $arQuery['tables'] ); + $this->addFields( $arQuery['fields'] ); + $this->addJoinConds( $arQuery['joins'] ); $this->addFields( [ 'ar_title', 'ar_namespace' ] ); } else { $this->limit = $this->getParameter( 'limit' ) ?: 10; + $this->addTables( 'archive' ); $this->addFields( [ 'ar_title', 'ar_namespace', 'ar_timestamp', 'ar_rev_id', 'ar_id' ] ); } @@ -87,16 +92,11 @@ class ApiQueryDeletedRevisions 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' ] ); @@ -116,10 +116,19 @@ class ApiQueryDeletedRevisions 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'] ) ) { @@ -127,9 +136,9 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase { // (shouldn't be able to get here without 'deletedhistory', but // check it again just in case) if ( !$user->isAllowed( 'deletedhistory' ) ) { - $bitmask = Revision::DELETED_USER; + $bitmask = RevisionRecord::DELETED_USER; } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) { - $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED; + $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED; } else { $bitmask = 0; } @@ -229,7 +238,7 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase { $fit = $this->addPageSubItem( $pageMap[$row->ar_namespace][$row->ar_title], - $this->extractRevisionInfo( Revision::newFromArchiveRow( $row ), $row ), + $this->extractRevisionInfo( $revisionStore->newRevisionFromArchiveRow( $row ), $row ), 'rev' ); if ( !$fit ) {