* @file
*/
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Storage\NameTableAccessException;
+
/**
* Query module to enumerate deleted revisions for pages.
*
$params = $this->extractRequestParams( false );
$db = $this->getDB();
+ $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
$this->requireMaxOneParameter( $params, 'user', 'excludeuser' );
if ( $resultPageSet === null ) {
$this->parseParameters( $params );
- $arQuery = Revision::getArchiveQueryInfo();
+ $arQuery = $revisionStore->getArchiveQueryInfo();
$this->addTables( $arQuery['tables'] );
$this->addFields( $arQuery['fields'] );
$this->addJoinConds( $arQuery['joins'] );
}
if ( $this->fld_tags ) {
- $this->addTables( 'tag_summary' );
- $this->addJoinConds(
- [ 'tag_summary' => [ 'LEFT JOIN', [ 'ar_rev_id=ts_rev_id' ] ] ]
- );
- $this->addFields( 'ts_tags' );
+ $this->addFields( [ 'ts_tags' => ChangeTags::makeTagSummarySubquery( 'archive' ) ] );
}
if ( !is_null( $params['tag'] ) ) {
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
);
- $this->addWhereFld( 'ct_tag', $params['tag'] );
+ $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+ try {
+ $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+ } catch ( NameTableAccessException $exception ) {
+ // Return nothing.
+ $this->addWhere( '1=0' );
+ }
}
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;
}
$op = ( $dir == 'newer' ? '>' : '<' );
if ( $revCount !== 0 ) {
$this->dieContinueUsageIf( count( $cont ) != 2 );
- $rev = intval( $cont[0] );
+ $rev = (int)$cont[0];
$this->dieContinueUsageIf( strval( $rev ) !== $cont[0] );
$ar_id = (int)$cont[1];
$this->dieContinueUsageIf( strval( $ar_id ) !== $cont[1] );
"ar_id $op= $ar_id)" );
} else {
$this->dieContinueUsageIf( count( $cont ) != 4 );
- $ns = intval( $cont[0] );
+ $ns = (int)$cont[0];
$this->dieContinueUsageIf( strval( $ns ) !== $cont[0] );
$title = $db->addQuotes( $cont[1] );
$ts = $db->addQuotes( $db->timestamp( $cont[2] ) );
$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 ) {
protected function getExamplesMessages() {
return [
'action=query&prop=deletedrevisions&titles=Main%20Page|Talk:Main%20Page&' .
- 'drvprop=user|comment|content'
+ 'drvslots=*&drvprop=user|comment|content'
=> 'apihelp-query+deletedrevisions-example-titles',
'action=query&prop=deletedrevisions&revids=123456'
=> 'apihelp-query+deletedrevisions-example-revids',