Merge "Re-namespace RevisionStore and RevisionRecord classes"
[lhc/web/wiklou.git] / includes / api / ApiQueryUserContribs.php
index 3aa6183..36d4d34 100644 (file)
@@ -21,7 +21,8 @@
  */
 
 use MediaWiki\MediaWikiServices;
-use MediaWiki\Storage\RevisionRecord;
+use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Storage\NameTableAccessException;
 
 /**
  * This query action adds a list of a specified user's contributions to the output.
@@ -437,7 +438,7 @@ class ApiQueryUserContribs extends ApiQueryBase {
         * @return bool
         */
        private function prepareQuery( array $users, $limit, $which ) {
-               global $wgActorTableSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage, $wgChangeTagsSchemaMigrationStage;
 
                $this->resetQueryParams();
                $db = $this->getDB();
@@ -607,7 +608,17 @@ class ApiQueryUserContribs extends ApiQueryBase {
                        $this->addJoinConds(
                                [ 'change_tag' => [ 'INNER JOIN', [ $idField . ' = ct_rev_id' ] ] ]
                        );
-                       $this->addWhereFld( 'ct_tag', $this->params['tag'] );
+                       if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+                               $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                               try {
+                                       $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $this->params['tag'] ) );
+                               } catch ( NameTableAccessException $exception ) {
+                                       // Return nothing.
+                                       $this->addWhere( '1=0' );
+                               }
+                       } else {
+                               $this->addWhereFld( 'ct_tag', $this->params['tag'] );
+                       }
                }
 
                return true;