Merge "resourceloader: Simplify StringSet fallback"
[lhc/web/wiklou.git] / includes / api / ApiQueryAllDeletedRevisions.php
index 50afc7d..bae6885 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\NameTableAccessException;
 use MediaWiki\Storage\RevisionRecord;
 
 /**
@@ -42,6 +43,8 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
         * @return void
         */
        protected function run( ApiPageSet $resultPageSet = null ) {
+               global $wgChangeTagsSchemaMigrationStage;
+
                // Before doing anything at all, let's check permissions
                $this->checkUserRightsAny( 'deletedhistory' );
 
@@ -73,7 +76,7 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                                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'
                                        );
                                }
@@ -83,7 +86,7 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                                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'
                                        );
                                }
@@ -136,7 +139,17 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                        $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 ) {