Merge "build: Upgrade stylelint-config-wikimedia to 0.5.0 and make pass"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 29 Nov 2018 03:35:50 +0000 (03:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 29 Nov 2018 03:35:50 +0000 (03:35 +0000)
46 files changed:
includes/DefaultSettings.php
includes/Storage/DerivedPageDataUpdater.php
includes/api/ApiBase.php
includes/api/ApiQueryAllDeletedRevisions.php
includes/api/ApiQueryDeletedRevisions.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQueryUserContribs.php
includes/changetags/ChangeTags.php
includes/installer/MssqlUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/OracleUpdater.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteUpdater.php
includes/jobqueue/jobs/CategoryMembershipChangeJob.php
maintenance/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/mssql/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/mssql/tables.sql
maintenance/oracle/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/oracle/tables.sql
maintenance/populateChangeTagDef.php
maintenance/postgres/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/postgres/tables.sql
maintenance/sqlite/archives/patch-actor-table.sql
maintenance/sqlite/archives/patch-comment-table.sql
maintenance/sqlite/archives/patch-drop-ct_tag.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-filearchive-fa_actor.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-filearchive-fa_description_id.sql [new file with mode: 0644]
maintenance/tables.sql
tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php
tests/phpunit/includes/RevisionDbTestBase.php
tests/phpunit/includes/RevisionTest.php
tests/phpunit/includes/api/ApiBlockTest.php
tests/phpunit/includes/api/ApiDeleteTest.php
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/includes/api/ApiUnblockTest.php
tests/phpunit/includes/api/ApiUserrightsTest.php
tests/phpunit/includes/changetags/ChangeTagsTest.php
tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php
tests/phpunit/includes/page/PageArchiveMcrTest.php
tests/phpunit/includes/page/PageArchivePreMcrTest.php
tests/phpunit/includes/page/PageArchiveTestBase.php
tests/phpunit/includes/page/WikiPageDbTestBase.php
tests/phpunit/maintenance/populateChangeTagDefTest.php [deleted file]

index 44c5364..358b466 100644 (file)
@@ -37,6 +37,7 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * @cond file_level_code
@@ -7565,7 +7566,10 @@ $wgJobClasses = [
        'refreshLinksPrioritized' => RefreshLinksJob::class,
        'refreshLinksDynamic' => RefreshLinksJob::class,
        'activityUpdateJob' => ActivityUpdateJob::class,
-       'categoryMembershipChange' => CategoryMembershipChangeJob::class,
+       'categoryMembershipChange' => function ( Title $title, $params = [] ) {
+               $pc = MediaWikiServices::getInstance()->getParserCache();
+               return new CategoryMembershipChangeJob( $pc, $title, $params );
+       },
        'clearUserWatchlist' => ClearUserWatchlistJob::class,
        'cdnPurge' => CdnPurgeJob::class,
        'userGroupExpiry' => UserGroupExpiryJob::class,
@@ -8989,7 +8993,7 @@ $wgInterwikiPrefixDisplayTypes = [];
  * @since 1.30
  * @var int One of the MIGRATION_* constants
  */
-$wgCommentTableSchemaMigrationStage = MIGRATION_OLD;
+$wgCommentTableSchemaMigrationStage = MIGRATION_NEW;
 
 /**
  * RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
@@ -9030,20 +9034,6 @@ $wgMultiContentRevisionSchemaMigrationStage = SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_
  */
 $wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_OLD;
 
-/**
- * change_tag table schema migration stage.
- *
- * - MIGRATION_OLD: Do not use change_tag_def table or ct_tag_id.
- * - MIGRATION_WRITE_BOTH: Write to the change_tag_def table and ct_tag_id, but read from
- *   the old schema. This is different from the formal definition of the constants
- * - MIGRATION_WRITE_NEW: Behaves the same as MIGRATION_WRITE_BOTH
- * - MIGRATION_NEW: Use the change_tag_def table and ct_tag_id, do not read/write ct_tag
- *
- * @since 1.32
- * @var int One of the MIGRATION_* constants
- */
-$wgChangeTagsSchemaMigrationStage = MIGRATION_NEW;
-
 /**
  * Flag to enable Partial Blocks. This allows an admin to prevent a user from editing specific pages
  * or namespaces.
index d837a53..1fc41f0 100644 (file)
@@ -1395,12 +1395,9 @@ class DerivedPageDataUpdater implements IDBAccessObject {
                        // the recent change entry (also done via deferred updates) and carry over any
                        // bot/deletion/IP flags, ect.
                        $this->jobQueueGroup->lazyPush(
-                               new CategoryMembershipChangeJob(
+                               CategoryMembershipChangeJob::newSpec(
                                        $this->getTitle(),
-                                       [
-                                               'pageId' => $this->getPageId(),
-                                               'revTimestamp' => $this->revision->getTimestamp(),
-                                       ]
+                                       $this->revision->getTimestamp()
                                )
                        );
                }
index 1149d1e..32156d8 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\MediaWikiServices;
 
 /**
  * This abstract class implements many basic API functions, and is the base of
@@ -2069,11 +2070,41 @@ abstract class ApiBase extends ContextSource {
                foreach ( (array)$actions as $action ) {
                        $errors = array_merge( $errors, $title->getUserPermissionsErrors( $action, $user ) );
                }
+
                if ( $errors ) {
+                       // track block notices
+                       if ( $this->getConfig()->get( 'EnableBlockNoticeStats' ) ) {
+                               $this->trackBlockNotices( $errors );
+                       }
+
                        $this->dieStatus( $this->errorArrayToStatus( $errors, $user ) );
                }
        }
 
+       /**
+        * Keep track of errors messages resulting from a block
+        *
+        * @param array $errors
+        */
+       private function trackBlockNotices( array $errors ) {
+               $errorMessageKeys = [
+                       'blockedtext',
+                       'blockedtext-partial',
+                       'autoblockedtext',
+                       'systemblockedtext',
+               ];
+
+               $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
+
+               foreach ( $errors as $error ) {
+                       if ( in_array( $error[0], $errorMessageKeys ) ) {
+                               $wiki = $this->getConfig()->get( 'DBname' );
+                               $statsd->increment( 'BlockNotices.' . $wiki . '.MediaWikiApi.returned' );
+                               break;
+                       }
+               }
+       }
+
        /**
         * Will only set a warning instead of failing if the global $wgDebugAPI
         * is set to true. Otherwise behaves exactly as self::dieWithError().
index 7b4f15e..70a77ad 100644 (file)
@@ -43,8 +43,6 @@ 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' );
 
@@ -139,16 +137,12 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
                        $this->addJoinConds(
                                [ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
                        );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
 
index 8f71c1c..e7d710d 100644 (file)
@@ -39,8 +39,6 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase {
        }
 
        protected function run( ApiPageSet $resultPageSet = null ) {
-               global $wgChangeTagsSchemaMigrationStage;
-
                $user = $this->getUser();
                // Before doing anything at all, let's check permissions
                $this->checkUserRightsAny( 'deletedhistory' );
@@ -91,16 +89,12 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase {
                        $this->addJoinConds(
                                [ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
                        );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
 
index e84b9b2..1da252e 100644 (file)
@@ -36,8 +36,6 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
        }
 
        public function execute() {
-               global $wgChangeTagsSchemaMigrationStage;
-
                // Before doing anything at all, let's check permissions
                $this->checkUserRightsAny( 'deletedhistory' );
 
@@ -145,16 +143,12 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                        $this->addJoinConds(
                                [ 'change_tag' => [ 'INNER JOIN', [ 'ar_rev_id=ct_rev_id' ] ] ]
                        );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
 
index ba04193..edf7002 100644 (file)
@@ -42,8 +42,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $fld_details = false, $fld_tags = false;
 
        public function execute() {
-               global $wgChangeTagsSchemaMigrationStage;
-
                $params = $this->extractRequestParams();
                $db = $this->getDB();
                $this->commentStore = CommentStore::getStore();
@@ -116,16 +114,12 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN',
                                [ 'log_id=ct_log_id' ] ] ] );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
 
index b1dcf0d..e33df5c 100644 (file)
@@ -143,8 +143,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
         * @param ApiPageSet|null $resultPageSet
         */
        public function run( $resultPageSet = null ) {
-               global $wgChangeTagsSchemaMigrationStage;
-
                $user = $this->getUser();
                /* Get the parameters of the request. */
                $params = $this->extractRequestParams();
@@ -365,16 +363,12 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                if ( !is_null( $params['tag'] ) ) {
                        $this->addTables( 'change_tag' );
                        $this->addJoinConds( [ 'change_tag' => [ 'INNER JOIN', [ 'rc_id=ct_rc_id' ] ] ] );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
 
index ac7ee0a..a6bf58a 100644 (file)
@@ -84,7 +84,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
        }
 
        protected function run( ApiPageSet $resultPageSet = null ) {
-               global $wgActorTableSchemaMigrationStage, $wgChangeTagsSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage;
 
                $params = $this->extractRequestParams( false );
                $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
@@ -197,16 +197,12 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
                        $this->addJoinConds(
                                [ 'change_tag' => [ 'INNER JOIN', [ 'rev_id=ct_rev_id' ] ] ]
                        );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
 
index f16f958..ae7c580 100644 (file)
@@ -321,7 +321,7 @@ class ApiQueryUserContribs extends ApiQueryBase {
         * @param int $limit
         */
        private function prepareQuery( array $users, $limit ) {
-               global $wgActorTableSchemaMigrationStage, $wgChangeTagsSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage;
 
                $this->resetQueryParams();
                $db = $this->getDB();
@@ -490,16 +490,12 @@ class ApiQueryUserContribs extends ApiQueryBase {
                        $this->addJoinConds(
                                [ 'change_tag' => [ 'INNER JOIN', [ $idField . ' = ct_rev_id' ] ] ]
                        );
-                       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'] );
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       try {
+                               $this->addWhereFld( 'ct_tag_id', $changeTagDefStore->getId( $this->params['tag'] ) );
+                       } catch ( NameTableAccessException $exception ) {
+                               // Return nothing.
+                               $this->addWhere( '1=0' );
                        }
                }
        }
index c6e8e1f..5e83f95 100644 (file)
@@ -262,8 +262,6 @@ class ChangeTags {
                &$rev_id = null, &$log_id = null, $params = null, RecentChange $rc = null,
                User $user = null
        ) {
-               global $wgChangeTagsSchemaMigrationStage;
-
                $tagsToAdd = array_filter( (array)$tagsToAdd ); // Make sure we're submitting all tags...
                $tagsToRemove = array_filter( (array)$tagsToRemove );
 
@@ -347,35 +345,27 @@ class ChangeTags {
                $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
                if ( count( $tagsToAdd ) ) {
                        $changeTagMapping = [];
-                       if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
-                               foreach ( $tagsToAdd as $tag ) {
-                                       $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag );
-                               }
-                               // T207881: update the counts at the end of the transaction
-                               $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) {
-                                       $dbw->update(
-                                               'change_tag_def',
-                                               [ 'ctd_count = ctd_count + 1' ],
-                                               [ 'ctd_name' => $tagsToAdd ],
-                                               __METHOD__
-                                       );
-                               } );
+                       foreach ( $tagsToAdd as $tag ) {
+                               $changeTagMapping[$tag] = $changeTagDefStore->acquireId( $tag );
                        }
+                       // T207881: update the counts at the end of the transaction
+                       $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd ) {
+                               $dbw->update(
+                                       'change_tag_def',
+                                       [ 'ctd_count = ctd_count + 1' ],
+                                       [ 'ctd_name' => $tagsToAdd ],
+                                       __METHOD__
+                               );
+                       } );
 
                        $tagsRows = [];
                        foreach ( $tagsToAdd as $tag ) {
-                               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                                       $tagName = null;
-                               } else {
-                                       $tagName = $tag;
-                               }
                                // Filter so we don't insert NULLs as zero accidentally.
                                // Keep in mind that $rc_id === null means "I don't care/know about the
                                // rc_id, just delete $tag on this revision/log entry". It doesn't
                                // mean "only delete tags on this revision/log WHERE rc_id IS NULL".
                                $tagsRows[] = array_filter(
                                        [
-                                               'ct_tag' => $tagName,
                                                'ct_rc_id' => $rc_id,
                                                'ct_log_id' => $log_id,
                                                'ct_rev_id' => $rev_id,
@@ -392,24 +382,16 @@ class ChangeTags {
                // delete from change_tag
                if ( count( $tagsToRemove ) ) {
                        foreach ( $tagsToRemove as $tag ) {
-                               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                                       $tagName = null;
-                                       $tagId = $changeTagDefStore->getId( $tag );
-                               } else {
-                                       $tagName = $tag;
-                                       $tagId = null;
-                               }
                                $conds = array_filter(
                                        [
-                                               'ct_tag' => $tagName,
                                                'ct_rc_id' => $rc_id,
                                                'ct_log_id' => $log_id,
                                                'ct_rev_id' => $rev_id,
-                                               'ct_tag_id' => $tagId,
+                                               'ct_tag_id' => $changeTagDefStore->getId( $tag ),
                                        ]
                                );
                                $dbw->delete( 'change_tag', $conds, __METHOD__ );
-                               if ( $dbw->affectedRows() && $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
+                               if ( $dbw->affectedRows() ) {
                                        // T207881: update the counts at the end of the transaction
                                        $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag ) {
                                                $dbw->update(
@@ -788,7 +770,7 @@ class ChangeTags {
        public static function modifyDisplayQuery( &$tables, &$fields, &$conds,
                &$join_conds, &$options, $filter_tag = ''
        ) {
-               global $wgChangeTagsSchemaMigrationStage, $wgUseTagFilter;
+               global $wgUseTagFilter;
 
                // Normalize to arrays
                $tables = (array)$tables;
@@ -817,24 +799,20 @@ class ChangeTags {
 
                        $tables[] = 'change_tag';
                        $join_conds['change_tag'] = [ 'INNER JOIN', $join_cond ];
-                       if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                               $filterTagIds = [];
-                               $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
-                               foreach ( (array)$filter_tag as $filterTagName ) {
-                                       try {
-                                               $filterTagIds[] = $changeTagDefStore->getId( $filterTagName );
-                                       } catch ( NameTableAccessException $exception ) {
-                                               // Return nothing.
-                                               $conds[] = '0';
-                                               break;
-                                       };
-                               }
+                       $filterTagIds = [];
+                       $changeTagDefStore = MediaWikiServices::getInstance()->getChangeTagDefStore();
+                       foreach ( (array)$filter_tag as $filterTagName ) {
+                               try {
+                                       $filterTagIds[] = $changeTagDefStore->getId( $filterTagName );
+                               } catch ( NameTableAccessException $exception ) {
+                                       // Return nothing.
+                                       $conds[] = '0';
+                                       break;
+                               };
+                       }
 
-                               if ( $filterTagIds !== [] ) {
-                                       $conds['ct_tag_id'] = $filterTagIds;
-                               }
-                       } else {
-                               $conds['ct_tag'] = $filter_tag;
+                       if ( $filterTagIds !== [] ) {
+                               $conds['ct_tag_id'] = $filterTagIds;
                        }
 
                        if (
@@ -855,8 +833,6 @@ class ChangeTags {
         * @throws MWException When unable to determine appropriate JOIN condition for tagging
         */
        public static function makeTagSummarySubquery( $tables ) {
-               global $wgChangeTagsSchemaMigrationStage;
-
                // Normalize to arrays
                $tables = (array)$tables;
 
@@ -873,15 +849,9 @@ class ChangeTags {
                        throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
                }
 
-               $tagTables[] = 'change_tag';
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                       $tagTables[] = 'change_tag_def';
-                       $join_cond_ts_tags = [ 'change_tag_def' => [ 'INNER JOIN', 'ct_tag_id=ctd_id' ] ];
-                       $field = 'ctd_name';
-               } else {
-                       $field = 'ct_tag';
-                       $join_cond_ts_tags = [];
-               }
+               $tagTables = [ 'change_tag', 'change_tag_def' ];
+               $join_cond_ts_tags = [ 'change_tag_def' => [ 'INNER JOIN', 'ct_tag_id=ctd_id' ] ];
+               $field = 'ctd_name';
 
                return wfGetDB( DB_REPLICA )->buildGroupConcatField(
                        ',', $tagTables, $field, $join_cond, $join_cond_ts_tags
@@ -948,32 +918,20 @@ class ChangeTags {
         * @since 1.25
         */
        public static function defineTag( $tag ) {
-               global $wgChangeTagsSchemaMigrationStage;
-
                $dbw = wfGetDB( DB_MASTER );
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
-                       $tagDef = [
-                               'ctd_name' => $tag,
-                               'ctd_user_defined' => 1,
-                               'ctd_count' => 0
-                       ];
-                       $dbw->upsert(
-                               'change_tag_def',
-                               $tagDef,
-                               [ 'ctd_name' ],
-                               [ 'ctd_user_defined' => 1 ],
-                               __METHOD__
-                       );
-               }
+               $tagDef = [
+                       'ctd_name' => $tag,
+                       'ctd_user_defined' => 1,
+                       'ctd_count' => 0
+               ];
+               $dbw->upsert(
+                       'change_tag_def',
+                       $tagDef,
+                       [ 'ctd_name' ],
+                       [ 'ctd_user_defined' => 1 ],
+                       __METHOD__
+               );
 
-               if ( $wgChangeTagsSchemaMigrationStage < MIGRATION_NEW ) {
-                       $dbw->replace(
-                               'valid_tag',
-                               [ 'vt_tag' ],
-                               [ 'vt_tag' => $tag ],
-                               __METHOD__
-                       );
-               }
                // clear the memcache of defined tags
                self::purgeTagCacheAll();
        }
@@ -987,28 +945,20 @@ class ChangeTags {
         * @since 1.25
         */
        public static function undefineTag( $tag ) {
-               global $wgChangeTagsSchemaMigrationStage;
-
                $dbw = wfGetDB( DB_MASTER );
 
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
-                       $dbw->update(
-                               'change_tag_def',
-                               [ 'ctd_user_defined' => 0 ],
-                               [ 'ctd_name' => $tag ],
-                               __METHOD__
-                       );
-
-                       $dbw->delete(
-                               'change_tag_def',
-                               [ 'ctd_name' => $tag, 'ctd_count' => 0 ],
-                               __METHOD__
-                       );
-               }
+               $dbw->update(
+                       'change_tag_def',
+                       [ 'ctd_user_defined' => 0 ],
+                       [ 'ctd_name' => $tag ],
+                       __METHOD__
+               );
 
-               if ( $wgChangeTagsSchemaMigrationStage < MIGRATION_NEW ) {
-                       $dbw->delete( 'valid_tag', [ 'vt_tag' => $tag ], __METHOD__ );
-               }
+               $dbw->delete(
+                       'change_tag_def',
+                       [ 'ctd_name' => $tag, 'ctd_count' => 0 ],
+                       __METHOD__
+               );
 
                // clear the memcache of defined tags
                self::purgeTagCacheAll();
@@ -1310,19 +1260,14 @@ class ChangeTags {
         * @since 1.25
         */
        public static function deleteTagEverywhere( $tag ) {
-               global $wgChangeTagsSchemaMigrationStage;
                $dbw = wfGetDB( DB_MASTER );
                $dbw->startAtomic( __METHOD__ );
 
                // delete from valid_tag and/or set ctd_user_defined = 0
                self::undefineTag( $tag );
 
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                       $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
-                       $conditions = [ 'ct_tag_id' => $tagId ];
-               } else {
-                       $conditions = [ 'ct_tag' => $tag ];
-               }
+               $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
+               $conditions = [ 'ct_tag_id' => $tagId ];
 
                // find out which revisions use this tag, so we can delete from tag_summary
                $result = $dbw->select( 'change_tag',
@@ -1338,17 +1283,9 @@ class ChangeTags {
                }
 
                // delete from change_tag
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                       $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
-                       $dbw->delete( 'change_tag', [ 'ct_tag_id' => $tagId ], __METHOD__ );
-               } else {
-                       $dbw->delete( 'change_tag', [ 'ct_tag' => $tag ], __METHOD__ );
-               }
-
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
-                       $dbw->delete( 'change_tag_def', [ 'ctd_name' => $tag ], __METHOD__ );
-               }
-
+               $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
+               $dbw->delete( 'change_tag', [ 'ct_tag_id' => $tagId ], __METHOD__ );
+               $dbw->delete( 'change_tag_def', [ 'ctd_name' => $tag ], __METHOD__ );
                $dbw->endAtomic( __METHOD__ );
 
                // give extensions a chance
@@ -1514,16 +1451,16 @@ class ChangeTags {
                        $cache->makeKey( 'valid-tags-db' ),
                        WANObjectCache::TTL_MINUTE * 5,
                        function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
-                               global $wgChangeTagsSchemaMigrationStage;
                                $dbr = wfGetDB( DB_REPLICA );
 
                                $setOpts += Database::getCacheSetOptions( $dbr );
 
-                               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                                       $tags = self::listExplicitlyDefinedTagsNewBackend();
-                               } else {
-                                       $tags = $dbr->selectFieldValues( 'valid_tag', 'vt_tag', [], $fname );
-                               }
+                               $tags = $dbr->selectFieldValues(
+                                       'change_tag_def',
+                                       'ctd_name',
+                                       [ 'ctd_user_defined' => 1 ],
+                                       __METHOD__
+                               );
 
                                return array_filter( array_unique( $tags ) );
                        },
@@ -1535,22 +1472,6 @@ class ChangeTags {
                );
        }
 
-       /**
-        * Lists tags explicitly user defined tags. When ctd_user_defined is true.
-        *
-        * @return string[] Array of strings: tags
-        * @since 1.25
-        */
-       private static function listExplicitlyDefinedTagsNewBackend() {
-               $dbr = wfGetDB( DB_REPLICA );
-               return $dbr->selectFieldValues(
-                       'change_tag_def',
-                       'ctd_name',
-                       [ 'ctd_user_defined' => 1 ],
-                       __METHOD__
-               );
-       }
-
        /**
         * Lists tags defined by core or extensions using the ListDefinedTags hook.
         * Extensions need only define those tags they deem to be in active use.
@@ -1613,57 +1534,9 @@ class ChangeTags {
         * Returns a map of any tags used on the wiki to number of edits
         * tagged with them, ordered descending by the hitcount.
         * This does not include tags defined somewhere that have never been applied.
-        *
-        * Keeps a short-term cache in memory, so calling this multiple times in the
-        * same request should be fine.
-        *
         * @return array Array of string => int
         */
        public static function tagUsageStatistics() {
-               global $wgChangeTagsSchemaMigrationStage;
-               if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
-                       return self::newTagUsageStatistics();
-               }
-
-               $fname = __METHOD__;
-               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
-               return $cache->getWithSetCallback(
-                       $cache->makeKey( 'change-tag-statistics' ),
-                       WANObjectCache::TTL_MINUTE * 5,
-                       function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
-                               $dbr = wfGetDB( DB_REPLICA, 'vslow' );
-
-                               $setOpts += Database::getCacheSetOptions( $dbr );
-
-                               $res = $dbr->select(
-                                       'change_tag',
-                                       [ 'ct_tag', 'hitcount' => 'count(*)' ],
-                                       [],
-                                       $fname,
-                                       [ 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ]
-                               );
-
-                               $out = [];
-                               foreach ( $res as $row ) {
-                                       $out[$row->ct_tag] = $row->hitcount;
-                               }
-
-                               return $out;
-                       },
-                       [
-                               'checkKeys' => [ $cache->makeKey( 'change-tag-statistics' ) ],
-                               'lockTSE' => WANObjectCache::TTL_MINUTE * 5,
-                               'pcTTL' => WANObjectCache::TTL_PROC_LONG
-                       ]
-               );
-       }
-
-       /**
-        * Same self::tagUsageStatistics() but uses change_tag_def.
-        *
-        * @return array Array of string => int
-        */
-       private static function newTagUsageStatistics() {
                $dbr = wfGetDB( DB_REPLICA );
                $res = $dbr->select(
                        'change_tag_def',
index 4a12d4c..db4cbdf 100644 (file)
@@ -152,6 +152,9 @@ class MssqlUpdater extends DatabaseUpdater {
                        [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index 82cf7f4..532ccb0 100644 (file)
@@ -372,6 +372,9 @@ class MysqlUpdater extends DatabaseUpdater {
                        [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1,33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index 78b53aa..19c4cfe 100644 (file)
@@ -164,6 +164,9 @@ class OracleUpdater extends DatabaseUpdater {
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
 
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
+
                        // KEEP THIS AT THE BOTTOM!!
                        [ 'doRebuildDuplicateFunction' ],
 
index 71c1a52..5730743 100644 (file)
@@ -598,6 +598,9 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'addPgField', 'ipblocks', 'ipb_sitewide', 'SMALLINT NOT NULL DEFAULT 1' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index cba6a8a..2f39912 100644 (file)
@@ -191,6 +191,7 @@ class SqliteUpdater extends DatabaseUpdater {
 
                        // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
                        [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
+                       [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
 
                        [ 'migrateComments' ],
                        [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
@@ -204,6 +205,7 @@ class SqliteUpdater extends DatabaseUpdater {
                        [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
                        [ 'migrateArchiveText' ],
                        [ 'addTable', 'actor', 'patch-actor-table.sql' ],
+                       [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
                        [ 'migrateActors' ],
                        [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
                        [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
@@ -237,6 +239,9 @@ class SqliteUpdater extends DatabaseUpdater {
                        [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
                        [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
                        [ 'migrateImageCommentTemp' ],
+
+                       // 1.33
+                       [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                ];
        }
 
index c39823f..1c7647c 100644 (file)
@@ -41,11 +41,38 @@ class CategoryMembershipChangeJob extends Job {
 
        const ENQUEUE_FUDGE_SEC = 60;
 
-       public function __construct( Title $title, array $params ) {
+       /**
+        * @var ParserCache
+        */
+       private $parserCache;
+
+       /**
+        * @param Title $title The title of the page for which to update category emmbership.
+        * @param string $revisionTimestamp The timestamp of the new revision that triggered the job.
+        * @return JobSpecification
+        */
+       public static function newSpec( Title $title, $revisionTimestamp ) {
+               return new JobSpecification(
+                       'categoryMembershipChange',
+                       [
+                               'pageId' => $title->getArticleID(),
+                               'revTimestamp' => $revisionTimestamp,
+                       ],
+                       [],
+                       $title
+               );
+       }
+
+       /**
+        * Constructor for use by the Job Queue infrastructure.
+        * @note Don't call this when queueing a new instance, use newSpec() instead.
+        */
+       public function __construct( ParserCache $parserCache, Title $title, array $params ) {
                parent::__construct( 'categoryMembershipChange', $title, $params );
                // Only need one job per page. Note that ENQUEUE_FUDGE_SEC handles races where an
                // older revision job gets inserted while the newer revision job is de-duplicated.
                $this->removeDuplicates = true;
+               $this->parserCache = $parserCache;
        }
 
        public function run() {
@@ -236,10 +263,12 @@ class CategoryMembershipChangeJob extends Job {
                $options = $page->makeParserOptions( 'canonical' );
                $options->setTimestamp( $parseTimestamp );
 
-               // This could possibly use the parser cache if it checked the revision ID,
-               // but that's more complicated than it's worth.
-               $output = $renderer->getRenderedRevision( $rev->getRevisionRecord(), $options )
-                       ->getRevisionParserOutput();
+               $output = $rev->isCurrent() ? $this->parserCache->get( $page, $options ) : null;
+
+               if ( !$output || $output->getCacheRevisionId() !== $rev->getId() ) {
+                       $output = $renderer->getRenderedRevision( $rev->getRevisionRecord(), $options )
+                               ->getRevisionParserOutput();
+               }
 
                // array keys will cast numeric category names to ints
                // so we need to cast them back to strings to avoid breaking things!
diff --git a/maintenance/archives/patch-drop-ct_tag.sql b/maintenance/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..2f5881a
--- /dev/null
@@ -0,0 +1,10 @@
+-- T185355
+ALTER TABLE /*_*/change_tag MODIFY ct_tag_id int unsigned NOT NULL;
+
+DROP INDEX /*i*/change_tag_rc_tag_nonuniq ON /*_*/change_tag;
+DROP INDEX /*i*/change_tag_log_tag_nonuniq ON /*_*/change_tag;
+DROP INDEX /*i*/change_tag_rev_tag_nonuniq ON /*_*/change_tag;
+DROP INDEX /*i*/change_tag_tag_id ON /*_*/change_tag;
+
+ALTER TABLE /*_*/change_tag DROP COLUMN ct_tag;
+
diff --git a/maintenance/mssql/archives/patch-drop-ct_tag.sql b/maintenance/mssql/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..5498a1c
--- /dev/null
@@ -0,0 +1,22 @@
+-- T185355
+ALTER TABLE /*_*/change_tag ALTER COLUMN ct_tag INTEGER NOT NULL
+
+DECLARE @sql nvarchar(max),
+       @id sysname;--
+
+SET @sql = 'ALTER TABLE /*_*/change_tag DROP CONSTRAINT ';--
+
+SELECT @id = df.name
+FROM sys.default_constraints df
+JOIN sys.columns c
+       ON c.object_id = df.parent_object_id
+       AND c.column_id = df.parent_column_id
+WHERE
+       df.parent_object_id = OBJECT_ID('/*_*/change_tag')
+       AND c.name = 'ct_tag';--
+
+SET @sql = @sql + @id;--
+
+EXEC sp_executesql @sql;--
+
+ALTER TABLE /*_*/change_tag DROP COLUMN ct_tag;
index ec2f1fa..fd2fae7 100644 (file)
@@ -1398,24 +1398,17 @@ CREATE TABLE /*_*/change_tag (
   ct_log_id int NULL REFERENCES /*_*/logging(log_id),
   -- REVID for the change
   ct_rev_id int NULL REFERENCES /*_*/revision(rev_id),
-  -- Tag applied
-  ct_tag nvarchar(255) NOT NULL default '',
   -- Parameters for the tag, presently unused
   ct_params nvarchar(max) NULL,
   -- Foreign key to change_tag_def row
-  ct_tag_id int NULL CONSTRAINT ctd_tag_id__fk FOREIGN KEY REFERENCES /*_*/change_tag_def(ctd_id)
+  ct_tag_id int NOT NULL CONSTRAINT ctd_tag_id__fk FOREIGN KEY REFERENCES /*_*/change_tag_def(ctd_id)
 );
 
-CREATE INDEX /*i*/change_tag_rc_tag_nonuniq ON /*_*/change_tag (ct_rc_id,ct_tag);
-CREATE INDEX /*i*/change_tag_log_tag_nonuniq ON /*_*/change_tag (ct_log_id,ct_tag);
-CREATE INDEX /*i*/change_tag_rev_tag_nonuniq ON /*_*/change_tag (ct_rev_id,ct_tag);
-
 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id ON /*_*/change_tag (ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id,ct_tag_id);
 
 -- Covering index, so we can pull all the info only out of the index.
-CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT
diff --git a/maintenance/oracle/archives/patch-drop-ct_tag.sql b/maintenance/oracle/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..4c5d128
--- /dev/null
@@ -0,0 +1,9 @@
+-- T185355
+ALTER TABLE &mw_prefix.change_tag MODIFY &mw_prefix.ct_tag_id NUMBER NOT NULL;
+
+DROP INDEX &mw_prefix.change_tag_i03;
+DROP INDEX &mw_prefix.change_tag_i04;
+DROP INDEX &mw_prefix.change_tag_i05;
+DROP INDEX &mw_prefix.change_tag_i01;
+
+ALTER TABLE &mw_prefix.change_tag DROP COLUMN &mw_prefix.ct_tag;
index 1ccaabf..4c36fe1 100644 (file)
@@ -935,21 +935,15 @@ CREATE TABLE &mw_prefix.change_tag (
   ct_rc_id NUMBER NULL,
   ct_log_id NUMBER NULL,
   ct_rev_id NUMBER NULL,
-  ct_tag VARCHAR2(255) DEFAULT '///invalid///' NOT NULL,
   ct_params BLOB NULL,
-  ct_tag_id NUMBER NULL
+  ct_tag_id NUMBER NOT NULL
 );
 ALTER TABLE &mw_prefix.change_tag ADD CONSTRAINT &mw_prefix.change_tag_pk PRIMARY KEY (ct_id);
 
-CREATE INDEX &mw_prefix.change_tag_i03 ON &mw_prefix.change_tag (ct_rc_id,ct_tag);
-CREATE INDEX &mw_prefix.change_tag_i04 ON &mw_prefix.change_tag (ct_log_id,ct_tag);
-CREATE INDEX &mw_prefix.change_tag_i05 ON &mw_prefix.change_tag (ct_rev_id,ct_tag);
-
 CREATE UNIQUE INDEX &mw_prefix.change_tag_u04 ON &mw_prefix.change_tag (ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX &mw_prefix.change_tag_u05 ON &mw_prefix.change_tag (ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX &mw_prefix.change_tag_u06 ON &mw_prefix.change_tag (ct_rev_id,ct_tag_id);
 
-CREATE INDEX &mw_prefix.change_tag_i01 ON &mw_prefix.change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX &mw_prefix.change_tag_i02 ON &mw_prefix.change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 CREATE TABLE &mw_prefix.tag_summary (
index 7bec25a..9594137 100644 (file)
@@ -42,16 +42,6 @@ class PopulateChangeTagDef extends LoggedUpdateMaintenance {
                $this->addOption( 'set-user-tags-only', 'Only update ctd_user_defined from valid_tag table' );
        }
 
-       public function execute() {
-               global $wgChangeTagsSchemaMigrationStage;
-               if ( $wgChangeTagsSchemaMigrationStage === MIGRATION_OLD ) {
-                       // Return "success", but don't flag it as done so the next run will retry
-                       $this->output( '... Not run, $wgChangeTagsSchemaMigrationStage === MIGRATION_OLD' . "\n" );
-                       return true;
-               }
-               return parent::execute();
-       }
-
        protected function doDBUpdates() {
                $this->lbFactory = MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                $this->setBatchSize( $this->getOption( 'batch-size', $this->getBatchSize() ) );
diff --git a/maintenance/postgres/archives/patch-drop-ct_tag.sql b/maintenance/postgres/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..cbef6c9
--- /dev/null
@@ -0,0 +1,10 @@
+-- T185355
+ALTER TABLE /*_*/change_tag ALTER COLUMN ct_tag_id SET NOT NULL;
+
+DROP INDEX /*i*/change_tag_rc_tag_nonuniq;
+DROP INDEX /*i*/change_tag_log_tag_nonuniq;
+DROP INDEX /*i*/change_tag_rev_tag_nonuniq;
+DROP INDEX /*i*/change_tag_tag_id;
+
+ALTER TABLE /*_*/change_tag DROP COLUMN ct_tag;
+
index 96a0617..4f636ae 100644 (file)
@@ -804,21 +804,15 @@ CREATE TABLE change_tag (
   ct_rc_id   INTEGER      NULL,
   ct_log_id  INTEGER      NULL,
   ct_rev_id  INTEGER      NULL,
-  ct_tag     TEXT     NOT NULL DEFAULT '',
   ct_params  TEXT         NULL,
-  ct_tag_id  INTEGER      NULL
+  ct_tag_id  INTEGER  NOT NULL
 );
 ALTER SEQUENCE change_tag_ct_id_seq OWNED BY change_tag.ct_id;
 
-CREATE INDEX change_tag_rc_tag_nonuniq ON change_tag(ct_rc_id,ct_tag);
-CREATE INDEX change_tag_log_tag_nonuniq ON change_tag(ct_log_id,ct_tag);
-CREATE INDEX change_tag_rev_tag_nonuniq ON change_tag(ct_rev_id,ct_tag);
-
 CREATE UNIQUE INDEX change_tag_rc_tag_id ON change_tag(ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX change_tag_log_tag_id ON change_tag(ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX change_tag_rev_tag_id ON change_tag(ct_rev_id,ct_tag_id);
 
-CREATE INDEX change_tag_tag_id ON change_tag(ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX change_tag_tag_id_id ON change_tag(ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 CREATE SEQUENCE tag_summary_ts_id_seq;
index 1de2292..8350cfa 100644 (file)
@@ -204,61 +204,7 @@ CREATE INDEX /*i*/oi_actor_timestamp ON /*_*/oldimage (oi_actor,oi_timestamp);
 
 COMMIT;
 
-BEGIN;
-
-DROP TABLE IF EXISTS /*_*/filearchive_tmp;
-CREATE TABLE /*_*/filearchive_tmp (
-  fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
-  fa_name varchar(255) binary NOT NULL default '',
-  fa_archive_name varchar(255) binary default '',
-  fa_storage_group varbinary(16),
-  fa_storage_key varbinary(64) default '',
-  fa_deleted_user int,
-  fa_deleted_timestamp binary(14) default '',
-  fa_deleted_reason varbinary(767) default '',
-  fa_deleted_reason_id bigint unsigned NOT NULL DEFAULT 0,
-  fa_size int unsigned default 0,
-  fa_width int default 0,
-  fa_height int default 0,
-  fa_metadata mediumblob,
-  fa_bits int default 0,
-  fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
-  fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
-  fa_minor_mime varbinary(100) default "unknown",
-  fa_description varbinary(767) default '',
-  fa_description_id bigint unsigned NOT NULL DEFAULT 0,
-  fa_user int unsigned default 0,
-  fa_user_text varchar(255) binary DEFAULT '',
-  fa_actor bigint unsigned NOT NULL DEFAULT 0,
-  fa_timestamp binary(14) default '',
-  fa_deleted tinyint unsigned NOT NULL default 0,
-  fa_sha1 varbinary(32) NOT NULL default ''
-) /*$wgDBTableOptions*/;
-
-INSERT OR IGNORE INTO /*_*/filearchive_tmp (
-       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
-       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
-       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
-       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
-       fa_deleted, fa_sha1)
-  SELECT
-       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
-       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
-       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
-       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
-       fa_deleted, fa_sha1
-  FROM /*_*/filearchive;
-
-DROP TABLE /*_*/filearchive;
-ALTER TABLE /*_*/filearchive_tmp RENAME TO /*_*/filearchive;
-CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
-CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
-CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
-CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
-CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));
-CREATE INDEX /*i*/fa_actor_timestamp ON /*_*/filearchive (fa_actor,fa_timestamp);
-
-COMMIT;
+-- filearchive is done in patch-filearchive-fa_actor.sql
 
 BEGIN;
 
index 197ced3..d74c3a6 100644 (file)
@@ -250,59 +250,7 @@ CREATE INDEX /*i*/oi_sha1 ON /*_*/oldimage (oi_sha1(10));
 
 COMMIT;
 
-BEGIN;
-
-DROP TABLE IF EXISTS /*_*/filearchive_tmp;
-CREATE TABLE /*_*/filearchive_tmp (
-  fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
-  fa_name varchar(255) binary NOT NULL default '',
-  fa_archive_name varchar(255) binary default '',
-  fa_storage_group varbinary(16),
-  fa_storage_key varbinary(64) default '',
-  fa_deleted_user int,
-  fa_deleted_timestamp binary(14) default '',
-  fa_deleted_reason varbinary(767) default '',
-  fa_deleted_reason_id bigint unsigned NOT NULL DEFAULT 0,
-  fa_size int unsigned default 0,
-  fa_width int default 0,
-  fa_height int default 0,
-  fa_metadata mediumblob,
-  fa_bits int default 0,
-  fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
-  fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
-  fa_minor_mime varbinary(100) default "unknown",
-  fa_description varbinary(767) default '',
-  fa_description_id bigint unsigned NOT NULL DEFAULT 0,
-  fa_user int unsigned default 0,
-  fa_user_text varchar(255) binary,
-  fa_timestamp binary(14) default '',
-  fa_deleted tinyint unsigned NOT NULL default 0,
-  fa_sha1 varbinary(32) NOT NULL default ''
-) /*$wgDBTableOptions*/;
-
-INSERT OR IGNORE INTO /*_*/filearchive_tmp (
-       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
-       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
-       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
-       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
-       fa_deleted, fa_sha1)
-  SELECT
-       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
-       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
-       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
-       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
-       fa_deleted, fa_sha1
-  FROM /*_*/filearchive;
-
-DROP TABLE /*_*/filearchive;
-ALTER TABLE /*_*/filearchive_tmp RENAME TO /*_*/filearchive;
-CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
-CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
-CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
-CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
-CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));
-
-COMMIT;
+-- filearchive is done in patch-filearchive-fa_description_id.sql
 
 BEGIN;
 
diff --git a/maintenance/sqlite/archives/patch-drop-ct_tag.sql b/maintenance/sqlite/archives/patch-drop-ct_tag.sql
new file mode 100644 (file)
index 0000000..d5fd77f
--- /dev/null
@@ -0,0 +1,23 @@
+-- T185355
+
+CREATE TABLE /*_*/change_tag_tmp (
+  ct_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  ct_rc_id int NULL,
+  ct_log_id int unsigned NULL,
+  ct_rev_id int unsigned NULL,
+  ct_params blob NULL,
+  ct_tag_id int unsigned NOT NULL
+) /*$wgDBTableOptions*/;
+
+INSERT INTO /*_*/change_tag_tmp
+       SELECT ct_id, ct_rc_id, ct_log_id, ct_rev_id, ct_params, ct_tag_id
+               FROM /*_*/change_tag;
+
+DROP TABLE /*_*/change_tag;
+
+ALTER TABLE /*_*/change_tag_tmp RENAME TO /*_*/change_tag;
+
+CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id,ct_tag_id);
+CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id ON /*_*/change_tag (ct_log_id,ct_tag_id);
+CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id,ct_tag_id);
+CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
diff --git a/maintenance/sqlite/archives/patch-filearchive-fa_actor.sql b/maintenance/sqlite/archives/patch-filearchive-fa_actor.sql
new file mode 100644 (file)
index 0000000..179c29c
--- /dev/null
@@ -0,0 +1,61 @@
+--
+-- patch-filearchive-fa_actor.sql
+--
+-- Split from patch-actor-table.sql to work around SQLite unconditionally running
+-- patch-add-3d.sql on a fresh install, which wipes out fa_actor.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/filearchive_tmp;
+CREATE TABLE /*_*/filearchive_tmp (
+  fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  fa_name varchar(255) binary NOT NULL default '',
+  fa_archive_name varchar(255) binary default '',
+  fa_storage_group varbinary(16),
+  fa_storage_key varbinary(64) default '',
+  fa_deleted_user int,
+  fa_deleted_timestamp binary(14) default '',
+  fa_deleted_reason varbinary(767) default '',
+  fa_deleted_reason_id bigint unsigned NOT NULL DEFAULT 0,
+  fa_size int unsigned default 0,
+  fa_width int default 0,
+  fa_height int default 0,
+  fa_metadata mediumblob,
+  fa_bits int default 0,
+  fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
+  fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
+  fa_minor_mime varbinary(100) default "unknown",
+  fa_description varbinary(767) default '',
+  fa_description_id bigint unsigned NOT NULL DEFAULT 0,
+  fa_user int unsigned default 0,
+  fa_user_text varchar(255) binary DEFAULT '',
+  fa_actor bigint unsigned NOT NULL DEFAULT 0,
+  fa_timestamp binary(14) default '',
+  fa_deleted tinyint unsigned NOT NULL default 0,
+  fa_sha1 varbinary(32) NOT NULL default ''
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/filearchive_tmp (
+       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
+       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
+       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
+       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
+       fa_deleted, fa_sha1)
+  SELECT
+       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
+       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
+       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
+       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
+       fa_deleted, fa_sha1
+  FROM /*_*/filearchive;
+
+DROP TABLE /*_*/filearchive;
+ALTER TABLE /*_*/filearchive_tmp RENAME TO /*_*/filearchive;
+CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
+CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
+CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
+CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
+CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));
+CREATE INDEX /*i*/fa_actor_timestamp ON /*_*/filearchive (fa_actor,fa_timestamp);
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-filearchive-fa_description_id.sql b/maintenance/sqlite/archives/patch-filearchive-fa_description_id.sql
new file mode 100644 (file)
index 0000000..c5361ed
--- /dev/null
@@ -0,0 +1,60 @@
+--
+-- patch-filearchive-fa_description_id.sql
+--
+-- Split from patch-comment-table.sql to work around SQLite unconditionally running
+-- patch-add-3d.sql on a fresh install, which wipes out fa_description_id and
+-- fa_deleted_reason_id.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/filearchive_tmp;
+CREATE TABLE /*_*/filearchive_tmp (
+  fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  fa_name varchar(255) binary NOT NULL default '',
+  fa_archive_name varchar(255) binary default '',
+  fa_storage_group varbinary(16),
+  fa_storage_key varbinary(64) default '',
+  fa_deleted_user int,
+  fa_deleted_timestamp binary(14) default '',
+  fa_deleted_reason varbinary(767) default '',
+  fa_deleted_reason_id bigint unsigned NOT NULL DEFAULT 0,
+  fa_size int unsigned default 0,
+  fa_width int default 0,
+  fa_height int default 0,
+  fa_metadata mediumblob,
+  fa_bits int default 0,
+  fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
+  fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
+  fa_minor_mime varbinary(100) default "unknown",
+  fa_description varbinary(767) default '',
+  fa_description_id bigint unsigned NOT NULL DEFAULT 0,
+  fa_user int unsigned default 0,
+  fa_user_text varchar(255) binary,
+  fa_timestamp binary(14) default '',
+  fa_deleted tinyint unsigned NOT NULL default 0,
+  fa_sha1 varbinary(32) NOT NULL default ''
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/filearchive_tmp (
+       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
+       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
+       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
+       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
+       fa_deleted, fa_sha1)
+  SELECT
+       fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key,
+       fa_deleted_user, fa_deleted_timestamp, fa_deleted_reason, fa_size,
+       fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
+       fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp,
+       fa_deleted, fa_sha1
+  FROM /*_*/filearchive;
+
+DROP TABLE /*_*/filearchive;
+ALTER TABLE /*_*/filearchive_tmp RENAME TO /*_*/filearchive;
+CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
+CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
+CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
+CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
+CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));
+
+COMMIT;
index 3c8b598..72db8c3 100644 (file)
@@ -1846,23 +1846,17 @@ CREATE TABLE /*_*/change_tag (
   ct_log_id int unsigned NULL,
   -- REVID for the change
   ct_rev_id int unsigned NULL,
-  -- Tag applied, this will go away and be replaced with ct_tag_id
-  ct_tag varchar(255) NOT NULL default '',
   -- Parameters for the tag; used by some extensions
   ct_params blob NULL,
-  -- Foreign key to change_tag_def row, this will be "NOT NULL" once populated
-  ct_tag_id int unsigned NULL
+  -- Foreign key to change_tag_def row
+  ct_tag_id int unsigned NOT NULL
 ) /*$wgDBTableOptions*/;
 
-CREATE INDEX /*i*/change_tag_rc_tag_nonuniq ON /*_*/change_tag (ct_rc_id,ct_tag);
-CREATE INDEX /*i*/change_tag_log_tag_nonuniq ON /*_*/change_tag (ct_log_id,ct_tag);
-CREATE INDEX /*i*/change_tag_rev_tag_nonuniq ON /*_*/change_tag (ct_rev_id,ct_tag);
 
 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id ON /*_*/change_tag (ct_rc_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id ON /*_*/change_tag (ct_log_id,ct_tag_id);
 CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id ON /*_*/change_tag (ct_rev_id,ct_tag_id);
 -- Covering index, so we can pull all the info only out of the index.
-CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
 CREATE INDEX /*i*/change_tag_tag_id_id ON /*_*/change_tag (ct_tag_id,ct_rc_id,ct_rev_id,ct_log_id);
 
 -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT
index 0d6a439..fcd5016 100644 (file)
@@ -78,7 +78,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase {
                $this->setMwGlobals( [
                        'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
                        'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
-                       'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
+                       'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                        'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                ] );
 
index e5e5551..cfff088 100644 (file)
@@ -90,7 +90,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->setMwGlobals( [
                        'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
                        'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
-                       'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
+                       'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                        'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                ] );
 
index c053104..04f0793 100644 (file)
@@ -281,10 +281,14 @@ class RevisionTest extends MediaWikiTestCase {
         * @covers \MediaWiki\Revision\RevisionStore::newMutableRevisionFromArray
         */
        public function testConstructFromRowWithBadPageId() {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->overrideMwServices();
                Wikimedia\suppressWarnings();
-               $rev = new Revision( (object)[ 'rev_page' => 77777777 ] );
+               $rev = new Revision( (object)[
+                       'rev_page' => 77777777,
+                       'rev_comment_text' => '',
+                       'rev_comment_data' => null,
+               ] );
                $this->assertSame( 77777777, $rev->getPage() );
                Wikimedia\restoreWarnings();
        }
@@ -597,7 +601,7 @@ class RevisionTest extends MediaWikiTestCase {
         * @covers Revision::loadFromTitle
         */
        public function testLoadFromTitle() {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->overrideMwServices();
                $title = $this->getMockTitle();
@@ -634,7 +638,10 @@ class RevisionTest extends MediaWikiTestCase {
                $db->expects( $this->once() )
                        ->method( 'selectRow' )
                        ->with(
-                               $this->equalTo( [ 'revision', 'page', 'user' ] ),
+                               $this->equalTo( [
+                                       'revision', 'page', 'user',
+                                       'temp_rev_comment' => 'revision_comment_temp', 'comment_rev_comment' => 'comment',
+                               ] ),
                                // We don't really care about the fields are they come from the selectField methods
                                $this->isType( 'array' ),
                                $this->equalTo( $conditions ),
index 563d5e3..9898e53 100644 (file)
@@ -116,24 +116,6 @@ class ApiBlockTest extends ApiTestCase {
        }
 
        public function testBlockWithTag() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               ChangeTags::defineTag( 'custom tag' );
-
-               $this->doBlock( [ 'tags' => 'custom tag' ] );
-
-               $dbw = wfGetDB( DB_MASTER );
-               $this->assertSame( 1, (int)$dbw->selectField(
-                       [ 'change_tag', 'logging' ],
-                       'COUNT(*)',
-                       [ 'log_type' => 'block', 'ct_tag' => 'custom tag' ],
-                       __METHOD__,
-                       [],
-                       [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
-               ) );
-       }
-
-       public function testBlockWithTagNewBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
                ChangeTags::defineTag( 'custom tag' );
 
                $this->doBlock( [ 'tags' => 'custom tag' ] );
index f2db1b2..fc546ff 100644 (file)
@@ -74,37 +74,6 @@ class ApiDeleteTest extends ApiTestCase {
        }
 
        public function testDeleteWithTag() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $name = 'Help:' . ucfirst( __FUNCTION__ );
-
-               ChangeTags::defineTag( 'custom tag' );
-
-               $this->editPage( $name, 'Some text' );
-
-               $this->doApiRequestWithToken( [
-                       'action' => 'delete',
-                       'title' => $name,
-                       'tags' => 'custom tag',
-               ] );
-
-               $this->assertFalse( Title::newFromText( $name )->exists() );
-
-               $dbw = wfGetDB( DB_MASTER );
-               $this->assertSame( 'custom tag', $dbw->selectField(
-                       [ 'change_tag', 'logging' ],
-                       'ct_tag',
-                       [
-                               'log_namespace' => NS_HELP,
-                               'log_title' => ucfirst( __FUNCTION__ ),
-                       ],
-                       __METHOD__,
-                       [],
-                       [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
-               ) );
-       }
-
-       public function testDeleteWithTagNewBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
                $name = 'Help:' . ucfirst( __FUNCTION__ );
 
                ChangeTags::defineTag( 'custom tag' );
index 847316a..2161093 100644 (file)
@@ -1332,25 +1332,6 @@ class ApiEditPageTest extends ApiTestCase {
        }
 
        public function testEditWithTag() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $name = 'Help:' . ucfirst( __FUNCTION__ );
-
-               ChangeTags::defineTag( 'custom tag' );
-
-               $revId = $this->doApiRequestWithToken( [
-                       'action' => 'edit',
-                       'title' => $name,
-                       'text' => 'Some text',
-                       'tags' => 'custom tag',
-               ] )[0]['edit']['newrevid'];
-
-               $dbw = wfGetDB( DB_MASTER );
-               $this->assertSame( 'custom tag', $dbw->selectField(
-                       'change_tag', 'ct_tag', [ 'ct_rev_id' => $revId ], __METHOD__ ) );
-       }
-
-       public function testEditWithTagNewBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
                $name = 'Help:' . ucfirst( __FUNCTION__ );
 
                ChangeTags::defineTag( 'custom tag' );
index 24744df..6ebd835 100644 (file)
@@ -114,26 +114,7 @@ class ApiUnblockTest extends ApiTestCase {
                $this->doUnblock( [ 'user' => $this->blocker->getName() ] );
        }
 
-       // XXX These three tests copy-pasted from ApiBlockTest.php
-       public function testUnblockWithTag() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               ChangeTags::defineTag( 'custom tag' );
-
-               $this->doUnblock( [ 'tags' => 'custom tag' ] );
-
-               $dbw = wfGetDB( DB_MASTER );
-               $this->assertSame( 1, (int)$dbw->selectField(
-                       [ 'change_tag', 'logging' ],
-                       'COUNT(*)',
-                       [ 'log_type' => 'block', 'ct_tag' => 'custom tag' ],
-                       __METHOD__,
-                       [],
-                       [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
-               ) );
-       }
-
        public function testUnblockWithTagNewBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
                ChangeTags::defineTag( 'custom tag' );
 
                $this->doUnblock( [ 'tags' => 'custom tag' ] );
index 2534ad3..8cc0217 100644 (file)
@@ -188,31 +188,6 @@ class ApiUserrightsTest extends ApiTestCase {
        }
 
        public function testWithTag() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               ChangeTags::defineTag( 'custom tag' );
-
-               $user = $this->getMutableTestUser()->getUser();
-
-               $this->doSuccessfulRightsChange( 'sysop', [ 'tags' => 'custom tag' ], $user );
-
-               $dbr = wfGetDB( DB_REPLICA );
-               $this->assertSame(
-                       'custom tag',
-                       $dbr->selectField(
-                               [ 'change_tag', 'logging' ],
-                               'ct_tag',
-                               [
-                                       'ct_log_id = log_id',
-                                       'log_namespace' => NS_USER,
-                                       'log_title' => strtr( $user->getName(), ' ', '_' )
-                               ],
-                               __METHOD__
-                       )
-               );
-       }
-
-       public function testWithTagNewBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
                ChangeTags::defineTag( 'custom tag' );
 
                $user = $this->getMutableTestUser()->getUser();
index cb9dd41..8265af8 100644 (file)
@@ -331,74 +331,10 @@ class ChangeTagsTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $actual );
        }
 
-       public function testUpdateTagsMigrationOld() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'change_tag', '*' );
-               $dbw->delete( 'change_tag_def', '*' );
-
-               $rcId = 123;
-               ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
-               $dbr = wfGetDB( DB_REPLICA );
-
-               $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_id', 'ctd_count' ], '' );
-               $this->assertEquals( [], iterator_to_array( $res, false ) );
-
-               $expected2 = [
-                       (object)[
-                               'ct_tag' => 'tag1',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 123
-                       ],
-                       (object)[
-                               'ct_tag' => 'tag2',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 123
-                       ],
-               ];
-               $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
-               $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
-
-               $rcId = 124;
-               ChangeTags::updateTags( [ 'tag1', 'tag3' ], [], $rcId );
-
-               $dbr = wfGetDB( DB_REPLICA );
-
-               $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_id', 'ctd_count' ], '' );
-               $this->assertEquals( [], iterator_to_array( $res, false ) );
-
-               $expected2 = [
-                       (object)[
-                               'ct_tag' => 'tag1',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 123
-                       ],
-                       (object)[
-                               'ct_tag' => 'tag2',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 123
-                       ],
-                       (object)[
-                               'ct_tag' => 'tag1',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 124
-                       ],
-                       (object)[
-                               'ct_tag' => 'tag3',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 124
-                       ],
-               ];
-               $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
-               $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
-       }
-
-       public function testUpdateTagsMigrationWriteBoth() {
+       public function testUpdateTags() {
                // FIXME: fails under postgres
                $this->markTestSkippedIfDbType( 'postgres' );
 
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete( 'change_tag', '*' );
                $dbw->delete( 'change_tag_def', '*' );
@@ -425,17 +361,15 @@ class ChangeTagsTest extends MediaWikiTestCase {
 
                $expected2 = [
                        (object)[
-                               'ct_tag' => 'tag1',
                                'ct_tag_id' => 1,
                                'ct_rc_id' => 123
                        ],
                        (object)[
-                               'ct_tag' => 'tag2',
                                'ct_tag_id' => 2,
                                'ct_rc_id' => 123
                        ],
                ];
-               $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
+               $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' );
                $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
 
                $rcId = 124;
@@ -467,59 +401,27 @@ class ChangeTagsTest extends MediaWikiTestCase {
 
                $expected2 = [
                        (object)[
-                               'ct_tag' => 'tag1',
                                'ct_tag_id' => 1,
                                'ct_rc_id' => 123
                        ],
                        (object)[
-                               'ct_tag' => 'tag2',
                                'ct_tag_id' => 2,
                                'ct_rc_id' => 123
                        ],
                        (object)[
-                               'ct_tag' => 'tag1',
                                'ct_tag_id' => 1,
                                'ct_rc_id' => 124
                        ],
                        (object)[
-                               'ct_tag' => 'tag3',
                                'ct_tag_id' => 3,
                                'ct_rc_id' => 124
                        ],
                ];
-               $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
-               $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
-       }
-
-       public function testDeleteTagsMigrationOld() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'change_tag', '*' );
-               $dbw->delete( 'change_tag_def', '*' );
-
-               $rcId = 123;
-               ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
-               ChangeTags::updateTags( [], [ 'tag2' ], $rcId );
-
-               $dbr = wfGetDB( DB_REPLICA );
-
-               $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_id', 'ctd_count' ], '' );
-               $this->assertEquals( [], iterator_to_array( $res, false ) );
-
-               $expected2 = [
-                       (object)[
-                               'ct_tag' => 'tag1',
-                               'ct_tag_id' => null,
-                               'ct_rc_id' => 123
-                       ]
-               ];
-               $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
+               $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' );
                $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
        }
 
-       public function testDeleteTagsMigrationWriteBoth() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
+       public function testDeleteTags() {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete( 'change_tag', '*' );
                $dbw->delete( 'change_tag_def', '*' );
@@ -544,54 +446,15 @@ class ChangeTagsTest extends MediaWikiTestCase {
 
                $expected2 = [
                        (object)[
-                               'ct_tag' => 'tag1',
                                'ct_tag_id' => 1,
                                'ct_rc_id' => 123
                        ]
                ];
-               $res2 = $dbr->select( 'change_tag', [ 'ct_tag', 'ct_tag_id', 'ct_rc_id' ], '' );
+               $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' );
                $this->assertEquals( $expected2, iterator_to_array( $res2, false ) );
        }
 
-       public function testTagUsageStatisticsOldBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
-               $this->setMwGlobals( 'wgTagStatisticsNewTable', false );
-
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'change_tag', '*' );
-               $dbw->delete( 'change_tag_def', '*' );
-
-               $rcId = 123;
-               ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
-               $rcId = 124;
-               ChangeTags::updateTags( [ 'tag1' ], [], $rcId );
-
-               $this->assertEquals( [ 'tag1' => 2, 'tag2' => 1 ], ChangeTags::tagUsageStatistics() );
-       }
-
-       public function testTagUsageStatisticsNewMigrationOldBackedn() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $this->setMwGlobals( 'wgTagStatisticsNewTable', false );
-
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'change_tag', '*' );
-               $dbw->delete( 'change_tag_def', '*' );
-               MediaWikiServices::getInstance()->resetServiceForTesting( 'NameTableStoreFactory' );
-
-               $rcId = 123;
-               ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-
-               $rcId = 124;
-               ChangeTags::updateTags( [ 'tag1' ], [], $rcId );
-
-               $this->assertEquals( [ 'tag1' => 2, 'tag2' => 1 ], ChangeTags::tagUsageStatistics() );
-       }
-
-       public function testTagUsageStatisticsNewBackend() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $this->setMwGlobals( 'wgTagStatisticsNewTable', true );
-
+       public function testTagUsageStatistics() {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete( 'change_tag', '*' );
                $dbw->delete( 'change_tag_def', '*' );
@@ -606,57 +469,7 @@ class ChangeTagsTest extends MediaWikiTestCase {
                $this->assertEquals( [ 'tag1' => 2, 'tag2' => 1 ], ChangeTags::tagUsageStatistics() );
        }
 
-       public function testListExplicitlyDefinedTagsOld() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_OLD );
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'change_tag', '*' );
-               $dbw->delete( 'change_tag_def', '*' );
-               $dbw->delete( 'valid_tag', '*' );
-
-               $rcId = 123;
-               ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-               ChangeTags::defineTag( 'tag2' );
-
-               $this->assertEquals( [ 'tag2' ], ChangeTags::listExplicitlyDefinedTags() );
-               $dbr = wfGetDB( DB_REPLICA );
-               $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_user_defined' ], '' );
-               $this->assertEquals( [], iterator_to_array( $res, false ) );
-
-               $this->assertEquals( [ 'tag2' ], $dbr->selectFieldValues( 'valid_tag', 'vt_tag', '' ) );
-       }
-
-       public function testListExplicitlyDefinedTagsWriteBoth() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'change_tag', '*' );
-               $dbw->delete( 'change_tag_def', '*' );
-               $dbw->delete( 'valid_tag', '*' );
-
-               $rcId = 123;
-               ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId );
-               ChangeTags::defineTag( 'tag2' );
-
-               $this->assertEquals( [ 'tag2' ], ChangeTags::listExplicitlyDefinedTags() );
-               $dbr = wfGetDB( DB_REPLICA );
-
-               $expected = [
-                       (object)[
-                               'ctd_name' => 'tag1',
-                               'ctd_user_defined' => 0
-                       ],
-                       (object)[
-                               'ctd_name' => 'tag2',
-                               'ctd_user_defined' => 1
-                       ],
-               ];
-               $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_user_defined' ], '' );
-               $this->assertEquals( $expected, iterator_to_array( $res, false ) );
-
-               $this->assertEquals( [ 'tag2' ], $dbr->selectFieldValues( 'valid_tag', 'vt_tag', '' ) );
-       }
-
-       public function testListExplicitlyDefinedTagsNew() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
+       public function testListExplicitlyDefinedTags() {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete( 'change_tag', '*' );
                $dbw->delete( 'change_tag_def', '*' );
index 1f73324..9f88cd7 100644 (file)
@@ -61,13 +61,16 @@ class CategoryMembershipChangeJobTest extends MediaWikiTestCase {
         * @return RecentChange|null
         */
        private function getCategorizeRecentChangeForRevId( $revId ) {
-               return RecentChange::newFromConds(
+               $rc = RecentChange::newFromConds(
                        [
                                'rc_type' => RC_CATEGORIZE,
                                'rc_this_oldid' => $revId,
                        ],
                        __METHOD__
                );
+
+               $this->assertNotNull( $rc, 'rev__id = ' . $revId );
+               return $rc;
        }
 
        public function testRun_normalCategoryAddedAndRemoved() {
index 1e16097..ba4b2e2 100644 (file)
@@ -52,7 +52,7 @@ class PageArchiveMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->ipRev->getPageId() ),
                                'ar_comment_text' => 'just a test',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '2',
                                'ts_tags' => null,
                                'ar_id' => '2',
                                'ar_namespace' => '0',
@@ -72,7 +72,7 @@ class PageArchiveMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->firstRev->getPageId() ),
                                'ar_comment_text' => 'testing',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '1',
                                'ts_tags' => null,
                                'ar_id' => '1',
                                'ar_namespace' => '0',
index 4df4ee1..f8d4ef9 100644 (file)
@@ -54,7 +54,7 @@ class PageArchivePreMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->ipRev->getPageId() ),
                                'ar_comment_text' => 'just a test',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '2',
                                'ar_content_format' => null,
                                'ar_content_model' => null,
                                'ts_tags' => null,
@@ -79,7 +79,7 @@ class PageArchivePreMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->firstRev->getPageId() ),
                                'ar_comment_text' => 'testing',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '1',
                                'ar_content_format' => null,
                                'ar_content_model' => null,
                                'ts_tags' => null,
index ade8efd..26b6b52 100644 (file)
@@ -43,12 +43,14 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase {
                        [
                                'page',
                                'revision',
+                               'revision_comment_temp',
                                'ip_changes',
                                'text',
                                'archive',
                                'recentchanges',
                                'logging',
                                'page_props',
+                               'comment',
                        ]
                );
        }
@@ -80,7 +82,7 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase {
 
                $this->tablesUsed += $this->getMcrTablesToReset();
 
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() );
                $this->setMwGlobals(
index fee4583..439bd38 100644 (file)
@@ -463,12 +463,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                );
                $logId = $status->getValue();
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'], /* table */
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
                        [
                                'log_type',
                                'log_action',
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -485,7 +486,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
        }
 
@@ -512,12 +513,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                );
                $logId = $status->getValue();
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'], /* table */
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
                        [
                                'log_type',
                                'log_action',
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -534,7 +536,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
        }
 
@@ -563,12 +565,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                );
                $logId = $status->getValue();
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'], /* table */
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
                        [
                                'log_type',
                                'log_action',
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -585,7 +588,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
 
                $this->assertNull(
@@ -2266,10 +2269,11 @@ more stuff
                // Make sure the log entry looks good
                // log_params is not checked here
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'],
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'],
                        [
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -2284,7 +2288,7 @@ more stuff
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
        }
 
diff --git a/tests/phpunit/maintenance/populateChangeTagDefTest.php b/tests/phpunit/maintenance/populateChangeTagDefTest.php
deleted file mode 100644 (file)
index 8a88f19..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-<?php
-
-namespace MediaWiki\Tests\Maintenance;
-
-use PopulateChangeTagDef;
-
-/**
- * @group Database
- * @covers PopulateChangeTagDef
- */
-class PopulateChangeTagDefTest extends MaintenanceBaseTestCase {
-
-       public function getMaintenanceClass() {
-               return PopulateChangeTagDef::class;
-       }
-
-       public function setUp() {
-               parent::setUp();
-               $this->tablesUsed = [ 'change_tag', 'change_tag_def', 'updatelog' ];
-
-               $this->cleanChangeTagTables();
-               $this->insertChangeTagData();
-       }
-
-       private function cleanChangeTagTables() {
-               wfGetDB( DB_MASTER )->delete( 'change_tag', '*' );
-               wfGetDB( DB_MASTER )->delete( 'change_tag_def', '*' );
-               wfGetDB( DB_MASTER )->delete( 'updatelog', '*' );
-       }
-
-       private function insertChangeTagData() {
-               $changeTags = [];
-
-               $changeTags[] = [
-                       'ct_rc_id' => 1234,
-                       'ct_tag' => 'One Tag',
-               ];
-
-               $changeTags[] = [
-                       'ct_rc_id' => 1235,
-                       'ct_tag' => 'Two Tags',
-               ];
-
-               $changeTags[] = [
-                       'ct_log_id' => 1236,
-                       'ct_tag' => 'Two Tags',
-               ];
-
-               $changeTags[] = [
-                       'ct_rev_id' => 1237,
-                       'ct_tag' => 'Three Tags',
-               ];
-
-               $changeTags[] = [
-                       'ct_rc_id' => 1238,
-                       'ct_tag' => 'Three Tags',
-               ];
-
-               $changeTags[] = [
-                       'ct_log_id' => 1239,
-                       'ct_tag' => 'Three Tags',
-               ];
-
-               wfGetDB( DB_MASTER )->insert( 'change_tag', $changeTags );
-       }
-
-       public function testRun() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $this->maintenance->loadWithArgv( [ '--sleep', '0' ] );
-
-               $this->maintenance->execute();
-
-               $changeTagDefRows = [
-                       (object)[
-                               'ctd_name' => 'One Tag',
-                               'ctd_count' => 1,
-                       ],
-                       (object)[
-                               'ctd_name' => 'Two Tags',
-                               'ctd_count' => 2,
-                       ],
-                       (object)[
-                               'ctd_name' => 'Three Tags',
-                               'ctd_count' => 3,
-                       ],
-               ];
-
-               $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag_def' ],
-                       [ 'ctd_name', 'ctd_count' ],
-                       [],
-                       __METHOD__,
-                       [ 'ORDER BY' => 'ctd_count' ]
-               );
-
-               $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs, false ) );
-
-               // Check if change_tag is also backpopulated
-               $actualChangeTags = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag', 'change_tag_def' ],
-                       [ 'ct_tag', 'ct_tag_id', 'ctd_count' ],
-                       [],
-                       __METHOD__,
-                       [],
-                       [ 'change_tag_def' => [ 'LEFT JOIN', 'ct_tag_id=ctd_id' ] ]
-               );
-               $mapping = [
-                       'One Tag' => 1,
-                       'Two Tags' => 2,
-                       'Three Tags' => 3
-               ];
-               foreach ( $actualChangeTags as $row ) {
-                       $this->assertNotNull( $row->ct_tag_id );
-                       $this->assertEquals( $row->ctd_count, $mapping[$row->ct_tag] );
-               }
-       }
-
-       public function testRunUpdateHitCountMigrationNew() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
-               $changeTagDefBadRows = [
-                       [
-                               'ctd_name' => 'One Tag',
-                               'ctd_user_defined' => 0,
-                               'ctd_count' => 50,
-                       ],
-                       [
-                               'ctd_name' => 'Two Tags',
-                               'ctd_user_defined' => 0,
-                               'ctd_count' => 4,
-                       ],
-                       [
-                               'ctd_name' => 'Three Tags',
-                               'ctd_user_defined' => 0,
-                               'ctd_count' => 3,
-                       ],
-               ];
-               wfGetDB( DB_MASTER )->insert(
-                       'change_tag_def',
-                       $changeTagDefBadRows
-               );
-
-               $mapping = [
-                       'One Tag' => 1,
-                       'Two Tags' => 2,
-                       'Three Tags' => 3
-               ];
-               foreach ( $mapping as $tagName => $tagId ) {
-                       wfGetDB( DB_MASTER )->update(
-                               'change_tag',
-                               [ 'ct_tag_id' => $tagId ],
-                               [ 'ct_tag' => $tagName ]
-                       );
-               }
-
-               $this->maintenance->loadWithArgv( [ '--sleep', '0' ] );
-
-               $this->maintenance->execute();
-
-               $changeTagDefRows = [
-                       (object)[
-                               'ctd_name' => 'One Tag',
-                               'ctd_count' => 1,
-                       ],
-                       (object)[
-                               'ctd_name' => 'Two Tags',
-                               'ctd_count' => 2,
-                       ],
-                       (object)[
-                               'ctd_name' => 'Three Tags',
-                               'ctd_count' => 3,
-                       ],
-               ];
-
-               $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag_def' ],
-                       [ 'ctd_name', 'ctd_count' ],
-                       [],
-                       __METHOD__,
-                       [ 'ORDER BY' => 'ctd_count' ]
-               );
-
-               $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs, false ) );
-       }
-
-       public function testRunUpdateHitCountMigrationWriteBoth() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $changeTagDefBadRows = [
-                       [
-                               'ctd_name' => 'One Tag',
-                               'ctd_user_defined' => 0,
-                               'ctd_count' => 50,
-                       ],
-                       [
-                               'ctd_name' => 'Two Tags',
-                               'ctd_user_defined' => 0,
-                               'ctd_count' => 4,
-                       ],
-                       [
-                               'ctd_name' => 'Three Tags',
-                               'ctd_user_defined' => 0,
-                               'ctd_count' => 3,
-                       ],
-               ];
-               wfGetDB( DB_MASTER )->insert(
-                       'change_tag_def',
-                       $changeTagDefBadRows
-               );
-
-               $this->maintenance->loadWithArgv( [ '--sleep', '0' ] );
-
-               $this->maintenance->execute();
-
-               $changeTagDefRows = [
-                       (object)[
-                               'ctd_name' => 'One Tag',
-                               'ctd_count' => 1,
-                       ],
-                       (object)[
-                               'ctd_name' => 'Two Tags',
-                               'ctd_count' => 2,
-                       ],
-                       (object)[
-                               'ctd_name' => 'Three Tags',
-                               'ctd_count' => 3,
-                       ],
-               ];
-
-               $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag_def' ],
-                       [ 'ctd_name', 'ctd_count' ],
-                       [],
-                       __METHOD__,
-                       [ 'ORDER BY' => 'ctd_count' ]
-               );
-
-               $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs, false ) );
-       }
-
-       public function testDryRunMigrationNew() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
-               $this->maintenance->loadWithArgv( [ '--dry-run', '--sleep', '0' ] );
-
-               $this->maintenance->execute();
-
-               $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag_def' ],
-                       [ 'ctd_id', 'ctd_name' ]
-               );
-
-               $this->assertEquals( [], iterator_to_array( $actualChangeTagDefs, false ) );
-
-               $actualChangeTags = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag' ],
-                       [ 'ct_tag_id', 'ct_tag' ]
-               );
-
-               foreach ( $actualChangeTags as $row ) {
-                       $this->assertNull( $row->ct_tag_id );
-                       $this->assertNotNull( $row->ct_tag );
-               }
-       }
-
-       public function testDryRunMigrationWriteBoth() {
-               $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
-               $this->maintenance->loadWithArgv( [ '--dry-run', '--sleep', '0' ] );
-
-               $this->maintenance->execute();
-
-               $actualChangeTagDefs = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag_def' ],
-                       [ 'ctd_id', 'ctd_name' ]
-               );
-
-               $this->assertEquals( [], iterator_to_array( $actualChangeTagDefs, false ) );
-
-               $actualChangeTags = wfGetDB( DB_REPLICA )->select(
-                       [ 'change_tag' ],
-                       [ 'ct_tag_id', 'ct_tag' ]
-               );
-
-               foreach ( $actualChangeTags as $row ) {
-                       $this->assertNull( $row->ct_tag_id );
-                       $this->assertNotNull( $row->ct_tag );
-               }
-       }
-
-}