* @file
*/
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\NameTableAccessException;
+use MediaWiki\Storage\RevisionRecord;
+
/**
* A query action to enumerate revisions of a given page, or show top revisions
* of multiple pages. Various pieces of information may be shown - flags,
}
protected function run( ApiPageSet $resultPageSet = null ) {
+ global $wgChangeTagsSchemaMigrationStage;
+
$params = $this->extractRequestParams( false );
+ $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
// If any of those parameters are used, work in 'enumeration' mode.
// Enum mode can only be used when exactly one page is provided.
if ( $this->fld_user ) {
$opts[] = 'user';
}
- $revQuery = Revision::getQueryInfo( $opts );
+ $revQuery = $revisionStore->getQueryInfo( $opts );
$this->addTables( $revQuery['tables'] );
$this->addFields( $revQuery['fields'] );
$this->addJoinConds( $revQuery['joins'] );
$this->addJoinConds(
[ 'change_tag' => [ 'INNER JOIN', [ '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 ( $resultPageSet === null && $this->fetchContent ) {
if ( $params['user'] !== null || $params['excludeuser'] !== null ) {
// Paranoia: avoid brute force searches (T19342)
if ( !$this->getUser()->isAllowed( 'deletedhistory' ) ) {
- $bitmask = Revision::DELETED_USER;
+ $bitmask = RevisionRecord::DELETED_USER;
} elseif ( !$this->getUser()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
- $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
+ $bitmask = RevisionRecord::DELETED_USER | RevisionRecord::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
if ( $resultPageSet !== null ) {
$generated[] = $row->rev_id;
} else {
- $revision = new Revision( $row );
+ $revision = $revisionStore->newRevisionFromRow( $row );
$rev = $this->extractRevisionInfo( $revision, $row );
if ( $this->token !== null ) {
- $title = $revision->getTitle();
+ $title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
+ $revisionCompat = new Revision( $revision );
$tokenFunctions = $this->getTokenFunctions();
foreach ( $this->token as $t ) {
- $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revision );
+ $val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revisionCompat );
if ( $val === false ) {
$this->addWarning( [ 'apiwarn-tokennotallowed', $t ] );
} else {
protected function getExamplesMessages() {
return [
'action=query&prop=revisions&titles=API|Main%20Page&' .
- 'rvprop=timestamp|user|comment|content'
+ 'rvslots=*&rvprop=timestamp|user|comment|content'
=> 'apihelp-query+revisions-example-content',
'action=query&prop=revisions&titles=Main%20Page&rvlimit=5&' .
'rvprop=timestamp|user|comment'