* @file
*/
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\NameTableAccessException;
+use MediaWiki\Storage\RevisionRecord;
+
/**
* Query module to enumerate all deleted revisions.
*
}
/**
- * @param ApiPageSet $resultPageSet
+ * @param ApiPageSet|null $resultPageSet
* @return void
*/
protected function run( ApiPageSet $resultPageSet = null ) {
+ global $wgChangeTagsSchemaMigrationStage;
+
// Before doing anything at all, let's check permissions
$this->checkUserRightsAny( 'deletedhistory' );
$user = $this->getUser();
$db = $this->getDB();
$params = $this->extractRequestParams( false );
+ $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
$result = $this->getResult();
if ( !is_null( $params[$param] ) ) {
$p = $this->getModulePrefix();
$this->dieWithError(
- [ 'apierror-invalidparammix-cannotusewith', $p.$param, "{$p}user" ],
+ [ 'apierror-invalidparammix-cannotusewith', $p . $param, "{$p}user" ],
'invalidparammix'
);
}
if ( !is_null( $params[$param] ) ) {
$p = $this->getModulePrefix();
$this->dieWithError(
- [ 'apierror-invalidparammix-mustusewith', $p.$param, "{$p}user" ],
+ [ 'apierror-invalidparammix-mustusewith', $p . $param, "{$p}user" ],
'invalidparammix'
);
}
if ( $resultPageSet === null ) {
$this->parseParameters( $params );
- $arQuery = Revision::getArchiveQueryInfo();
+ $arQuery = $revisionStore->getArchiveQueryInfo();
$this->addTables( $arQuery['tables'] );
$this->addJoinConds( $arQuery['joins'] );
$this->addFields( $arQuery['fields'] );
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
);
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
+ }
+ } else {
+ $this->addWhereFld( 'ct_tag', $params['tag'] );
+ }
}
if ( $this->fetchContent ) {
// (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;
}
$generated[] = $row->ar_rev_id;
}
} else {
- $revision = Revision::newFromArchiveRow( $row );
+ $revision = $revisionStore->newRevisionFromArchiveRow( $row );
$rev = $this->extractRevisionInfo( $revision, $row );
if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
$index = $nextIndex++;
$pageMap[$row->ar_namespace][$row->ar_title] = $index;
- $title = $revision->getTitle();
+ $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
$a = [
'pageid' => $title->getArticleID(),
'revisions' => [ $rev ],