Mostly drop old comment schemas
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 4 Jan 2019 18:55:11 +0000 (13:55 -0500)
committerTim Starling <tstarling@wikimedia.org>
Thu, 7 Feb 2019 05:59:27 +0000 (16:59 +1100)
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4

53 files changed:
RELEASE-NOTES-1.33
includes/CommentStore.php
includes/DefaultSettings.php
includes/EditPage.php
includes/FileDeleteForm.php
includes/ProtectionForm.php
includes/ServiceWiring.php
includes/actions/McrUndoAction.php
includes/filerepo/file/LocalFile.php
includes/installer/DatabaseUpdater.php
includes/installer/MssqlUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/OracleUpdater.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteUpdater.php
includes/page/Article.php
includes/page/WikiPage.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/specials/SpecialBlock.php
includes/specials/SpecialEditTags.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialUserrights.php
maintenance/archives/patch-drop-comment-fields.sql [new file with mode: 0644]
maintenance/migrateComments.php
maintenance/mssql/archives/patch-drop-comment-fields.sql [new file with mode: 0644]
maintenance/mssql/tables.sql
maintenance/oracle/archives/patch-drop-comment-fields.sql [new file with mode: 0644]
maintenance/oracle/tables.sql
maintenance/postgres/tables.sql
maintenance/sqlite/archives/patch-archive-drop-ar_comment.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-filearchive-drop-fa_description.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-image-drop-img_description.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-ipblocks-drop-ipb_reason.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-logging-drop-log_comment.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-oldimage-drop-oi_description.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-protected_titles-drop-pt_reason.sql [new file with mode: 0644]
maintenance/sqlite/archives/patch-recentchanges-drop-rc_comment.sql [new file with mode: 0644]
maintenance/tables.sql
tests/parser/ParserTestRunner.php
tests/phpunit/includes/ActorMigrationTest.php
tests/phpunit/includes/CommentStoreTest.php
tests/phpunit/includes/CommentStoreTest.sql [new file with mode: 0644]
tests/phpunit/includes/Revision/RevisionQueryInfoTest.php
tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php
tests/phpunit/includes/RevisionDbTestBase.php
tests/phpunit/includes/RevisionTest.php
tests/phpunit/includes/deferred/LinksUpdateTest.php
tests/phpunit/includes/logging/DatabaseLogEntryTest.php
tests/phpunit/includes/page/PageArchiveTestBase.php
tests/phpunit/includes/page/WikiPageDbTestBase.php
tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php

index 57984f6..8105446 100644 (file)
@@ -35,6 +35,8 @@ production.
 * $wgEnableParserCache, deprecated since 1.26, was removed.
   If disabling the parser cache is still desirable,
   set `$wgParserCacheType = CACHE_NONE;` instead.
+* $wgCommentTableSchemaMigrationStage has been removed. Extension code finding
+  it unset should treat it as being MIGRATION_NEW.
 
 === New features in 1.33 ===
 * (T96041) __EXPECTUNUSEDCATEGORY__ on a category page causes the category
index cba7a15..1a60bb7 100644 (file)
@@ -82,7 +82,11 @@ class CommentStore {
         */
        protected $key = null;
 
-       /** @var int One of the MIGRATION_* constants */
+       /**
+        * @var int One of the MIGRATION_* constants
+        * @todo Deprecate and remove once extensions seem unlikely to need to use
+        *  it for migration anymore.
+        */
        protected $stage;
 
        /** @var array[] Cache for `self::getJoin()` */
@@ -94,7 +98,8 @@ class CommentStore {
        /**
         * @param Language $lang Language to use for comment truncation. Defaults
         *  to content language.
-        * @param int $migrationStage One of the MIGRATION_* constants
+        * @param int $migrationStage One of the MIGRATION_* constants. Always
+        *  MIGRATION_NEW for MediaWiki core since 1.33.
         */
        public function __construct( Language $lang, $migrationStage ) {
                $this->stage = $migrationStage;
@@ -109,10 +114,10 @@ class CommentStore {
         * @return CommentStore
         */
        public static function newKey( $key ) {
-               global $wgCommentTableSchemaMigrationStage;
                wfDeprecated( __METHOD__, '1.31' );
-               $store = new CommentStore( MediaWikiServices::getInstance()->getContentLanguage(),
-                       $wgCommentTableSchemaMigrationStage );
+               $store = new CommentStore(
+                       MediaWikiServices::getInstance()->getContentLanguage(), MIGRATION_NEW
+               );
                $store->key = $key;
                return $store;
        }
index 31b0988..e6b44ed 100644 (file)
@@ -8964,13 +8964,6 @@ $wgExperiencedUserMemberSince = 30; # days
  */
 $wgInterwikiPrefixDisplayTypes = [];
 
-/**
- * Comment table schema migration stage.
- * @since 1.30
- * @var int One of the MIGRATION_* constants
- */
-$wgCommentTableSchemaMigrationStage = MIGRATION_NEW;
-
 /**
  * RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
  * Use the SCHEMA_COMPAT_XXX flags. Supported values:
index 4599564..300c5f3 100644 (file)
@@ -3250,15 +3250,13 @@ ERROR;
         * @return array
         */
        private function getSummaryInputAttributes( array $inputAttrs = null ) {
-               $conf = $this->context->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
+               // Unicode codepoints.
                return ( is_array( $inputAttrs ) ? $inputAttrs : [] ) + [
                        'id' => 'wpSummary',
                        'name' => 'wpSummary',
-                       'maxlength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                       'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                        'tabindex' => 1,
                        'size' => 60,
                        'spellcheck' => 'true',
index 8866a88..5aa6edf 100644 (file)
@@ -246,9 +246,6 @@ class FileDeleteForm {
        private function showForm() {
                global $wgOut, $wgUser, $wgRequest;
 
-               $conf = RequestContext::getMain()->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
-
                $wgOut->addModules( 'mediawiki.action.delete.file' );
 
                $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $wgUser->isWatched( $this->title );
@@ -282,13 +279,13 @@ class FileDeleteForm {
 
                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
+               // Unicode codepoints.
                $fields[] = new OOUI\FieldLayout(
                        new OOUI\TextInputWidget( [
                                'name' => 'wpReason',
                                'inputId' => 'wpReason',
                                'tabIndex' => 2,
-                               'maxLength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                               'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                'infusable' => true,
                                'value' => $wgRequest->getText( 'wpReason' ),
                                'autofocus' => true,
index bb8eba1..ac4ca77 100644 (file)
@@ -355,7 +355,6 @@ class ProtectionForm {
                $lang = $context->getLanguage();
                $conf = $context->getConfig();
                $cascadingRestrictionLevels = $conf->get( 'CascadingRestrictionLevels' );
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                $out = '';
                if ( !$this->disabled ) {
                        $output->addModules( 'mediawiki.legacy.protect' );
@@ -502,10 +501,10 @@ class ProtectionForm {
 
                        // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                        // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-                       // Unicode codepoints (or 180 UTF-8 bytes for old schema).
+                       // Unicode codepoints.
                        // Subtract arbitrary 75 to leave some space for the autogenerated null edit's summary
                        // and other texts chosen by dropdown menus on this page.
-                       $maxlength = $oldCommentSchema ? 180 : CommentStore::COMMENT_CHARACTER_LIMIT - 75;
+                       $maxlength = CommentStore::COMMENT_CHARACTER_LIMIT - 75;
 
                        $out .= Xml::openElement( 'table', [ 'id' => 'mw-protect-table3' ] ) .
                                Xml::openElement( 'tbody' );
index 9a94389..44ca502 100644 (file)
@@ -85,7 +85,7 @@ return [
        'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
                return new CommentStore(
                        $services->getContentLanguage(),
-                       $services->getMainConfig()->get( 'CommentTableSchemaMigrationStage' )
+                       MIGRATION_NEW
                );
        },
 
index b60820c..47bbdc0 100644 (file)
@@ -358,8 +358,6 @@ class McrUndoAction extends FormAction {
 
        protected function getFormFields() {
                $request = $this->getRequest();
-               $config = $this->context->getConfig();
-               $oldCommentSchema = $config->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                $ret = [
                        'diff' => [
                                'type' => 'info',
@@ -375,7 +373,7 @@ class McrUndoAction extends FormAction {
                                'name' => 'wpSummary',
                                'cssclass' => 'mw-summary',
                                'label-message' => 'summary',
-                               'maxlength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                               'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                'value' => $request->getVal( 'wpSummary', '' ),
                                'size' => 60,
                                'spellcheck' => 'true',
index 878e82d..789d7c5 100644 (file)
@@ -1431,7 +1431,7 @@ class LocalFile extends File {
                $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [],
                $createNullRevision = true
        ) {
-               global $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage;
 
                if ( is_null( $user ) ) {
                        global $wgUser;
@@ -1528,6 +1528,7 @@ class LocalFile extends File {
                                'oi_width' => 'img_width',
                                'oi_height' => 'img_height',
                                'oi_bits' => 'img_bits',
+                               'oi_description_id' => 'img_description_id',
                                'oi_timestamp' => 'img_timestamp',
                                'oi_metadata' => 'img_metadata',
                                'oi_media_type' => 'img_media_type',
@@ -1537,39 +1538,6 @@ class LocalFile extends File {
                        ];
                        $joins = [];
 
-                       if ( $wgCommentTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) {
-                               $fields['oi_description'] = 'img_description';
-                       }
-                       if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
-                               $fields['oi_description_id'] = 'img_description_id';
-                       }
-
-                       if ( $wgCommentTableSchemaMigrationStage !== MIGRATION_OLD &&
-                               $wgCommentTableSchemaMigrationStage !== MIGRATION_NEW
-                       ) {
-                               // Upgrade any rows that are still old-style. Otherwise an upgrade
-                               // might be missed if a deletion happens while the migration script
-                               // is running.
-                               $res = $dbw->select(
-                                       [ 'image' ],
-                                       [ 'img_name', 'img_description' ],
-                                       [
-                                               'img_name' => $this->getName(),
-                                               'img_description_id' => 0,
-                                       ],
-                                       __METHOD__
-                               );
-                               foreach ( $res as $row ) {
-                                       $imgFields = $commentStore->insert( $dbw, 'img_description', $row->img_description );
-                                       $dbw->update(
-                                               'image',
-                                               $imgFields,
-                                               [ 'img_name' => $row->img_name ],
-                                               __METHOD__
-                                       );
-                               }
-                       }
-
                        if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
                                $fields['oi_user'] = 'img_user';
                                $fields['oi_user_text'] = 'img_user_text';
@@ -2470,7 +2438,7 @@ class LocalFileDeleteBatch {
        }
 
        protected function doDBInserts() {
-               global $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage;
 
                $now = time();
                $dbw = $this->file->repo->getMasterDB();
@@ -2515,6 +2483,7 @@ class LocalFileDeleteBatch {
                                'fa_media_type' => 'img_media_type',
                                'fa_major_mime' => 'img_major_mime',
                                'fa_minor_mime' => 'img_minor_mime',
+                               'fa_description_id' => 'img_description_id',
                                'fa_timestamp' => 'img_timestamp',
                                'fa_sha1' => 'img_sha1'
                        ];
@@ -2525,39 +2494,6 @@ class LocalFileDeleteBatch {
                                $commentStore->insert( $dbw, 'fa_deleted_reason', $this->reason )
                        );
 
-                       if ( $wgCommentTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) {
-                               $fields['fa_description'] = 'img_description';
-                       }
-                       if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
-                               $fields['fa_description_id'] = 'img_description_id';
-                       }
-
-                       if ( $wgCommentTableSchemaMigrationStage !== MIGRATION_OLD &&
-                               $wgCommentTableSchemaMigrationStage !== MIGRATION_NEW
-                       ) {
-                               // Upgrade any rows that are still old-style. Otherwise an upgrade
-                               // might be missed if a deletion happens while the migration script
-                               // is running.
-                               $res = $dbw->select(
-                                       [ 'image' ],
-                                       [ 'img_name', 'img_description' ],
-                                       [
-                                               'img_name' => $this->file->getName(),
-                                               'img_description_id' => 0,
-                                       ],
-                                       __METHOD__
-                               );
-                               foreach ( $res as $row ) {
-                                       $imgFields = $commentStore->insert( $dbw, 'img_description', $row->img_description );
-                                       $dbw->update(
-                                               'image',
-                                               $imgFields,
-                                               [ 'img_name' => $row->img_name ],
-                                               __METHOD__
-                                       );
-                               }
-                       }
-
                        if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
                                $fields['fa_user'] = 'img_user';
                                $fields['fa_user_text'] = 'img_user_text';
index 43000b8..d64e2d7 100644 (file)
@@ -1261,10 +1261,7 @@ abstract class DatabaseUpdater {
         * @since 1.30
         */
        protected function migrateComments() {
-               global $wgCommentTableSchemaMigrationStage;
-               if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_NEW &&
-                       !$this->updateRowExists( 'MigrateComments' )
-               ) {
+               if ( !$this->updateRowExists( 'MigrateComments' ) ) {
                        $this->output(
                                "Migrating comments to the 'comments' table, printing progress markers. For large\n" .
                                "databases, you may want to hit Ctrl-C and do this manually with\n" .
@@ -1281,20 +1278,14 @@ abstract class DatabaseUpdater {
         * @since 1.32
         */
        protected function migrateImageCommentTemp() {
-               global $wgCommentTableSchemaMigrationStage;
-
                if ( $this->tableExists( 'image_comment_temp' ) ) {
-                       if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) {
-                               $this->output( "Merging image_comment_temp into the image table\n" );
-                               $task = $this->maintenance->runChild(
-                                       MigrateImageCommentTemp::class, 'migrateImageCommentTemp.php'
-                               );
-                               $task->setForce();
-                               $ok = $task->execute();
-                               $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
-                       } else {
-                               $ok = true;
-                       }
+                       $this->output( "Merging image_comment_temp into the image table\n" );
+                       $task = $this->maintenance->runChild(
+                               MigrateImageCommentTemp::class, 'migrateImageCommentTemp.php'
+                       );
+                       $task->setForce();
+                       $ok = $task->execute();
+                       $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
                        if ( $ok ) {
                                $this->dropTable( 'image_comment_temp' );
                        }
index 2f1c0f3..75f3894 100644 (file)
@@ -156,6 +156,7 @@ class MssqlUpdater extends DatabaseUpdater {
                        [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                        [ 'dropTable', 'valid_tag' ],
                        [ 'dropTable', 'tag_summary' ],
+                       [ 'dropField', 'protected_titles', 'pt_reason', 'patch-drop-comment-fields.sql' ],
                ];
        }
 
index f7362cb..2e3fdba 100644 (file)
@@ -374,6 +374,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                        [ 'dropTable', 'valid_tag' ],
                        [ 'dropTable', 'tag_summary' ],
+                       [ 'dropField', 'protected_titles', 'pt_reason', 'patch-drop-comment-fields.sql' ],
                ];
        }
 
index e9be744..d3a7b13 100644 (file)
@@ -167,6 +167,7 @@ class OracleUpdater extends DatabaseUpdater {
                        [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                        [ 'dropTable', 'valid_tag' ],
                        [ 'dropTable', 'tag_summary' ],
+                       [ 'dropField', 'protected_titles', 'pt_reason', 'patch-drop-comment-fields.sql' ],
 
                        // KEEP THIS AT THE BOTTOM!!
                        [ 'doRebuildDuplicateFunction' ],
index 7c0d3e3..75877a1 100644 (file)
@@ -600,6 +600,24 @@ class PostgresUpdater extends DatabaseUpdater {
                        [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                        [ 'dropTable', 'valid_tag' ],
                        [ 'dropTable', 'tag_summary' ],
+                       [ 'dropPgField', 'archive', 'ar_comment' ],
+                       [ 'dropDefault', 'archive', 'ar_comment_id' ],
+                       [ 'dropPgField', 'ipblocks', 'ipb_reason' ],
+                       [ 'dropDefault', 'ipblocks', 'ipb_reason_id' ],
+                       [ 'dropPgField', 'image', 'img_description' ],
+                       [ 'dropDefault', 'image', 'img_description_id' ],
+                       [ 'dropPgField', 'oldimage', 'oi_description' ],
+                       [ 'dropDefault', 'oldimage', 'oi_description_id' ],
+                       [ 'dropPgField', 'filearchive', 'fa_deleted_reason' ],
+                       [ 'dropDefault', 'filearchive', 'fa_deleted_reason_id' ],
+                       [ 'dropPgField', 'filearchive', 'fa_description' ],
+                       [ 'dropDefault', 'filearchive', 'fa_description_id' ],
+                       [ 'dropPgField', 'recentchanges', 'rc_comment' ],
+                       [ 'dropDefault', 'recentchanges', 'rc_comment_id' ],
+                       [ 'dropPgField', 'logging', 'log_comment' ],
+                       [ 'dropDefault', 'logging', 'log_comment_id' ],
+                       [ 'dropPgField', 'protected_titles', 'pt_reason' ],
+                       [ 'dropDefault', 'protected_titles', 'pt_reason_id' ],
                ];
        }
 
@@ -928,7 +946,7 @@ END;
 
        protected function setDefault( $table, $field, $default ) {
                $info = $this->db->fieldInfo( $table, $field );
-               if ( $info->defaultValue() !== $default ) {
+               if ( $info && $info->defaultValue() !== $default ) {
                        $this->output( "Changing '$table.$field' default value\n" );
                        $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT "
                                . $this->db->addQuotes( $default ) );
index 1d99b87..17ced50 100644 (file)
@@ -241,6 +241,14 @@ class SqliteUpdater extends DatabaseUpdater {
                        [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
                        [ 'dropTable', 'valid_tag' ],
                        [ 'dropTable', 'tag_summary' ],
+                       [ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
+                       [ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
+                       [ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
+                       [ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
+                       [ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
+                       [ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
+                       [ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
+                       [ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
                ];
        }
 
index 9b5e5a5..983f069 100644 (file)
@@ -1946,15 +1946,13 @@ class Article implements Page {
 
                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
-               $conf = $this->getContext()->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
+               // Unicode codepoints.
                $fields[] = new OOUI\FieldLayout(
                        new OOUI\TextInputWidget( [
                                'name' => 'wpReason',
                                'inputId' => 'wpReason',
                                'tabIndex' => 2,
-                               'maxLength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                               'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                'infusable' => true,
                                'value' => $reason,
                                'autofocus' => true,
index 6217ee7..072c3c6 100644 (file)
@@ -2815,8 +2815,7 @@ class WikiPage implements Page, IDBAccessObject {
         */
        protected function archiveRevisions( $dbw, $id, $suppress ) {
                global $wgContentHandlerUseDB, $wgMultiContentRevisionSchemaMigrationStage,
-                       $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage,
-                       $wgDeleteRevisionsBatchSize;
+                       $wgActorTableSchemaMigrationStage, $wgDeleteRevisionsBatchSize;
 
                // Given the lock above, we can be confident in the title and page ID values
                $namespace = $this->getTitle()->getNamespace();
@@ -2942,9 +2941,7 @@ class WikiPage implements Page, IDBAccessObject {
                        $dbw->insert( 'archive', $rowsInsert, __METHOD__ );
 
                        $dbw->delete( 'revision', [ 'rev_id' => $revids ], __METHOD__ );
-                       if ( $wgCommentTableSchemaMigrationStage > MIGRATION_OLD ) {
-                               $dbw->delete( 'revision_comment_temp', [ 'revcomment_rev' => $revids ], __METHOD__ );
-                       }
+                       $dbw->delete( 'revision_comment_temp', [ 'revcomment_rev' => $revids ], __METHOD__ );
                        if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
                                $dbw->delete( 'revision_actor_temp', [ 'revactor_rev' => $revids ], __METHOD__ );
                        }
index b5d31ef..334fc73 100644 (file)
@@ -75,7 +75,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                }
 
                $illegalFileChars = $conf->get( 'IllegalFileChars' );
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
 
                // Build list of variables
                $skin = $context->getSkin();
@@ -123,8 +122,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ),
                        'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ),
                        'wgEnableUploads' => $conf->get( 'EnableUploads' ),
-                       'wgCommentByteLimit' => $oldCommentSchema ? 255 : null,
-                       'wgCommentCodePointLimit' => $oldCommentSchema ? null : CommentStore::COMMENT_CHARACTER_LIMIT,
+                       'wgCommentByteLimit' => null,
+                       'wgCommentCodePointLimit' => CommentStore::COMMENT_CHARACTER_LIMIT,
                ];
 
                Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars, $skin ] );
index 9c8882b..81b82d9 100644 (file)
@@ -148,7 +148,6 @@ class SpecialBlock extends FormSpecialPage {
                $suggestedDurations = self::getSuggestedDurations();
 
                $conf = $this->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                $enablePartialBlocks = $conf->get( 'EnablePartialBlocks' );
 
                $a = [];
@@ -243,8 +242,8 @@ class SpecialBlock extends FormSpecialPage {
                        'type' => 'selectandother',
                        // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                        // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-                       // Unicode codepoints (or 255 UTF-8 bytes for old schema).
-                       'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                       // Unicode codepoints.
+                       'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                        'maxlength-unit' => 'codepoints',
                        'options-message' => 'ipbreason-dropdown',
                        'section' => 'reason',
index 6198a84..d0bfcb0 100644 (file)
@@ -239,9 +239,6 @@ class SpecialEditTags extends UnlistedSpecialPage {
 
                // Show form if the user can submit
                if ( $this->isAllowed ) {
-                       $conf = $this->getConfig();
-                       $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
-
                        $form = Xml::openElement( 'form', [ 'method' => 'post',
                                        'action' => $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] ),
                                        'id' => 'mw-revdel-form-revisions' ] ) .
@@ -258,9 +255,9 @@ class SpecialEditTags extends UnlistedSpecialPage {
                                                        'id' => 'wpReason',
                                                        // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                                                        // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-                                                       // Unicode codepoints (or 255 UTF-8 bytes for old schema).
+                                                       // Unicode codepoints.
                                                        // "- 155" is to leave room for the auto-generated part of the log entry.
-                                                       'maxlength' => $oldCommentSchema ? 100 : CommentStore::COMMENT_CHARACTER_LIMIT - 155,
+                                                       'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT - 155,
                                                ] ) .
                                        '</td>' .
                                "</tr><tr>\n" .
index 599ab31..0234507 100644 (file)
@@ -333,14 +333,12 @@ class MovePageForm extends UnlistedSpecialPage {
 
                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
-               $conf = $this->getConfig();
-               $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
+               // Unicode codepoints.
                $fields[] = new OOUI\FieldLayout(
                        new OOUI\TextInputWidget( [
                                'name' => 'wpReason',
                                'id' => 'wpReason',
-                               'maxLength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                               'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                'infusable' => true,
                                'value' => $this->reason,
                        ] ),
index 50f3710..d5bb576 100644 (file)
@@ -421,9 +421,6 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $out->addModules( [ 'mediawiki.special.revisionDelete' ] );
                        $out->addModuleStyles( 'mediawiki.special' );
 
-                       $conf = $this->getConfig();
-                       $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
-
                        $form = Xml::openElement( 'form', [ 'method' => 'post',
                                        'action' => $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] ),
                                        'id' => 'mw-revdel-form-revisions' ] ) .
@@ -450,9 +447,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                                        'id' => 'wpReason',
                                                        // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                                                        // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-                                                       // Unicode codepoints (or 255 UTF-8 bytes for old schema).
+                                                       // Unicode codepoints.
                                                        // "- 155" is to leave room for the 'wpRevDeleteReasonList' value.
-                                                       'maxlength' => $oldCommentSchema ? 100 : CommentStore::COMMENT_CHARACTER_LIMIT - 155,
+                                                       'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT - 155,
                                                ] ) .
                                        '</td>' .
                                "</tr><tr>\n" .
index cd754ca..9654bb7 100644 (file)
@@ -769,9 +769,6 @@ class SpecialUndelete extends SpecialPage {
                                'content' => new OOUI\HtmlSnippet( $this->msg( 'undeleteextrahelp' )->parseAsBlock() )
                        ] );
 
-                       $conf = $this->getConfig();
-                       $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
-
                        $fields[] = new OOUI\FieldLayout(
                                new OOUI\TextInputWidget( [
                                        'name' => 'wpComment',
@@ -781,8 +778,8 @@ class SpecialUndelete extends SpecialPage {
                                        'autofocus' => true,
                                        // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                                        // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-                                       // Unicode codepoints (or 255 UTF-8 bytes for old schema).
-                                       'maxLength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                                       // Unicode codepoints.
+                                       'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                ] ),
                                [
                                        'label' => $this->msg( 'undeletecomment' )->text(),
index 3c2907b..6e6d905 100644 (file)
@@ -714,8 +714,6 @@ class UserrightsPage extends SpecialPage {
                                ->rawParams( $userToolLinks )->parse()
                );
                if ( $canChangeAny ) {
-                       $conf = $this->getConfig();
-                       $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
                        $this->getOutput()->addHTML(
                                $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
                                $grouplist .
@@ -730,8 +728,8 @@ class UserrightsPage extends SpecialPage {
                                                                'id' => 'wpReason',
                                                                // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
                                                                // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
-                                                               // Unicode codepoints (or 255 UTF-8 bytes for old schema).
-                                                               'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
+                                                               // Unicode codepoints.
+                                                               'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
                                                        ] ) .
                                                "</td>
                                        </tr>
diff --git a/maintenance/archives/patch-drop-comment-fields.sql b/maintenance/archives/patch-drop-comment-fields.sql
new file mode 100644 (file)
index 0000000..a4b248d
--- /dev/null
@@ -0,0 +1,38 @@
+--
+-- patch-drop-comment-fields.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+ALTER TABLE /*_*/archive
+  DROP COLUMN ar_comment,
+  ALTER COLUMN ar_comment_id DROP DEFAULT;
+
+ALTER TABLE /*_*/ipblocks
+  DROP COLUMN ipb_reason,
+  ALTER COLUMN ipb_reason_id DROP DEFAULT;
+
+ALTER TABLE /*_*/image
+  DROP COLUMN img_description,
+  ALTER COLUMN img_description_id DROP DEFAULT;
+
+ALTER TABLE /*_*/oldimage
+  DROP COLUMN oi_description,
+  ALTER COLUMN oi_description_id DROP DEFAULT;
+
+ALTER TABLE /*_*/filearchive
+  DROP COLUMN fa_deleted_reason,
+  ALTER COLUMN fa_deleted_reason_id DROP DEFAULT,
+  DROP COLUMN fa_description,
+  ALTER COLUMN fa_description_id DROP DEFAULT;
+
+ALTER TABLE /*_*/recentchanges
+  DROP COLUMN rc_comment,
+  ALTER COLUMN rc_comment_id DROP DEFAULT;
+
+ALTER TABLE /*_*/logging
+  DROP COLUMN log_comment,
+  ALTER COLUMN log_comment_id DROP DEFAULT;
+
+ALTER TABLE /*_*/protected_titles
+  DROP COLUMN pt_reason,
+  ALTER COLUMN pt_reason_id DROP DEFAULT;
index 555f2d1..8025df1 100644 (file)
@@ -47,15 +47,6 @@ class MigrateComments extends LoggedUpdateMaintenance {
        }
 
        protected function doDBUpdates() {
-               global $wgCommentTableSchemaMigrationStage;
-
-               if ( $wgCommentTableSchemaMigrationStage < MIGRATION_WRITE_NEW ) {
-                       $this->output(
-                               "...cannot update while \$wgCommentTableSchemaMigrationStage < MIGRATION_WRITE_NEW\n"
-                       );
-                       return false;
-               }
-
                $this->migrateToTemp(
                        'revision', 'rev_id', 'rev_comment', 'revcomment_rev', 'revcomment_comment_id'
                );
@@ -138,13 +129,18 @@ class MigrateComments extends LoggedUpdateMaintenance {
         * @param string $oldField Old comment field name
         */
        protected function migrate( $table, $primaryKey, $oldField ) {
+               $dbw = $this->getDB( DB_MASTER );
+               if ( !$dbw->fieldExists( $table, $oldField, __METHOD__ ) ) {
+                       $this->output( "No need to migrate $table.$oldField, field does not exist\n" );
+                       return;
+               }
+
                $newField = $oldField . '_id';
                $primaryKey = (array)$primaryKey;
                $pkFilter = array_flip( $primaryKey );
                $this->output( "Beginning migration of $table.$oldField to $table.$newField\n" );
                wfWaitForSlaves();
 
-               $dbw = $this->getDB( DB_MASTER );
                $next = '1=1';
                $countUpdated = 0;
                $countComments = 0;
@@ -229,6 +225,12 @@ class MigrateComments extends LoggedUpdateMaintenance {
         * @param string $newField New comment field name
         */
        protected function migrateToTemp( $table, $primaryKey, $oldField, $newPrimaryKey, $newField ) {
+               $dbw = $this->getDB( DB_MASTER );
+               if ( !$dbw->fieldExists( $table, $oldField, __METHOD__ ) ) {
+                       $this->output( "No need to migrate $table.$oldField, field does not exist\n" );
+                       return;
+               }
+
                $newTable = $table . '_comment_temp';
                $this->output( "Beginning migration of $table.$oldField to $newTable.$newField\n" );
                wfWaitForSlaves();
diff --git a/maintenance/mssql/archives/patch-drop-comment-fields.sql b/maintenance/mssql/archives/patch-drop-comment-fields.sql
new file mode 100644 (file)
index 0000000..bdc8c91
--- /dev/null
@@ -0,0 +1,55 @@
+--
+-- patch-drop-comment-fields.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+DECLARE @sql nvarchar(max),
+       @id sysname;
+
+ALTER TABLE /*_*/archive DROP CONSTRAINT DF_ar_comment, COLUMN ar_comment;
+ALTER TABLE /*_*/archive DROP CONSTRAINT DF_ar_comment_id;
+
+ALTER TABLE /*_*/ipblocks DROP CONSTRAINT DF_ipb_reason, COLUMN ipb_reason;
+ALTER TABLE /*_*/ipblocks DROP CONSTRAINT DF_ipb_reason_id;
+
+ALTER TABLE /*_*/image DROP CONSTRAINT DF_img_description, COLUMN img_description;
+ALTER TABLE /*_*/image DROP CONSTRAINT DF_img_description_id;
+
+ALTER TABLE /*_*/oldimage DROP CONSTRAINT DF_oi_description, COLUMN oi_description;
+ALTER TABLE /*_*/oldimage DROP CONSTRAINT DF_oi_description_id;
+
+ALTER TABLE /*_*/filearchive DROP CONSTRAINT DF_fa_deleted_reason, COLUMN fa_deleted_reason;
+ALTER TABLE /*_*/filearchive DROP CONSTRAINT DF_fa_deleted_reason_id;
+ALTER TABLE /*_*/filearchive DROP CONSTRAINT DF_fa_description, COLUMN fa_description;
+ALTER TABLE /*_*/filearchive DROP CONSTRAINT DF_fa_description_id;
+
+SET @sql = 'ALTER TABLE /*_*/recentchanges 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('/*_*/recentchanges')
+       AND c.name = 'rc_comment';
+SET @sql = @sql + @id;
+EXEC sp_executesql @sql;
+ALTER TABLE /*_*/recentchanges DROP COLUMN rc_comment;
+ALTER TABLE /*_*/recentchanges DROP CONSTRAINT DF_rc_comment_id;
+
+SET @sql = 'ALTER TABLE /*_*/logging 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('/*_*/logging')
+       AND c.name = 'log_comment';
+SET @sql = @sql + @id;
+EXEC sp_executesql @sql;
+ALTER TABLE /*_*/logging DROP COLUMN log_comment;
+ALTER TABLE /*_*/logging DROP CONSTRAINT DF_log_comment_id;
+
+ALTER TABLE /*_*/protected_titles DROP CONSTRAINT DF_pt_reason, COLUMN pt_reason;
+ALTER TABLE /*_*/protected_titles DROP CONSTRAINT DF_pt_reason_id;
index 4ecc6db..72ea69d 100644 (file)
@@ -270,8 +270,7 @@ CREATE TABLE /*_*/archive (
    ar_id int NOT NULL PRIMARY KEY IDENTITY,
    ar_namespace SMALLINT NOT NULL DEFAULT 0,
    ar_title NVARCHAR(255) NOT NULL DEFAULT '',
-   ar_comment NVARCHAR(255) NOT NULL CONSTRAINT DF_ar_comment DEFAULT '',
-   ar_comment_id bigint NOT NULL CONSTRAINT DF_ar_comment_id DEFAULT 0 CONSTRAINT FK_ar_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+   ar_comment_id bigint NOT NULL CONSTRAINT FK_ar_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
    ar_user INT CONSTRAINT ar_user__user_id__fk FOREIGN KEY REFERENCES /*_*/mwuser(user_id),
    ar_user_text NVARCHAR(255) NOT NULL CONSTRAINT DF_ar_user_text DEFAULT '',
    ar_actor bigint NOT NULL CONSTRAINT DF_ar_actor DEFAULT 0,
@@ -651,12 +650,8 @@ CREATE TABLE /*_*/ipblocks (
   -- User name of blocker
   ipb_by_text nvarchar(255) NOT NULL default '',
 
-  -- Text comment made by blocker.
-  ipb_reason nvarchar(255) NOT NULL CONSTRAINT DF_ipb_reason DEFAULT '',
-
   -- Key to comment_id. Text comment made by blocker.
-  -- ("DEFAULT 0" is temporary, signaling that ipb_reason should be used)
-  ipb_reason_id bigint NOT NULL CONSTRAINT DF_ipb_reason_id DEFAULT 0 CONSTRAINT FK_ipb_reason_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  ipb_reason_id bigint NOT NULL CONSTRAINT FK_ipb_reason_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
 
   -- Creation (or refresh) date in standard YMDHMS form.
   -- IP blocks expire automatically.
@@ -776,8 +771,7 @@ CREATE TABLE /*_*/image (
 
   -- Description field as entered by the uploader.
   -- This is displayed in image upload history and logs.
-  img_description nvarchar(255) NOT NULL CONSTRAINT DF_img_description DEFAULT '',
-  img_description_id bigint NOT NULL CONSTRAINT DF_img_description_id DEFAULT 0 CONSTRAINT FK_img_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  img_description_id bigint NOT NULL CONSTRAINT FK_img_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
 
   -- user_id and user_name of uploader.
   img_user int REFERENCES /*_*/mwuser(user_id) ON DELETE SET NULL,
@@ -825,8 +819,7 @@ CREATE TABLE /*_*/oldimage (
   oi_width int NOT NULL default 0,
   oi_height int NOT NULL default 0,
   oi_bits int NOT NULL default 0,
-  oi_description nvarchar(255) NOT NULL CONSTRAINT DF_oi_description DEFAULT '',
-  oi_description_id bigint NOT NULL CONSTRAINT DF_oi_description_id DEFAULT 0 CONSTRAINT FK_oi_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  oi_description_id bigint NOT NULL CONSTRAINT FK_oi_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
   oi_user int REFERENCES /*_*/mwuser(user_id),
   oi_user_text nvarchar(255) NOT NULL CONSTRAINT DF_oi_user_text DEFAULT '',
   oi_actor bigint NOT NULL CONSTRAINT DF_oi_actor DEFAULT 0,
@@ -877,8 +870,7 @@ CREATE TABLE /*_*/filearchive (
   -- Deletion information, if this file is deleted.
   fa_deleted_user int,
   fa_deleted_timestamp varchar(14) default '',
-  fa_deleted_reason nvarchar(max) CONSTRAINT DF_fa_deleted_reason DEFAULT '',
-  fa_deleted_reason_id bigint NOT NULL CONSTRAINT DF_fa_deleted_reason_id DEFAULT 0 CONSTRAINT FK_fa_deleted_reason_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  fa_deleted_reason_id bigint NOT NULL CONSTRAINT FK_fa_deleted_reason_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
 
   -- Duped fields from image
   fa_size int default 0,
@@ -889,8 +881,7 @@ CREATE TABLE /*_*/filearchive (
   fa_media_type varchar(16) default null,
   fa_major_mime varchar(16) not null default 'unknown',
   fa_minor_mime nvarchar(100) default 'unknown',
-  fa_description nvarchar(255) CONSTRAINT DF_fa_description DEFAULT '',
-  fa_description_id bigint NOT NULL CONSTRAINT DF_fa_description_id DEFAULT 0 CONSTRAINT FK_fa_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  fa_description_id bigint NOT NULL CONSTRAINT FK_fa_description_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
   fa_user int default 0 REFERENCES /*_*/mwuser(user_id) ON DELETE SET NULL,
   fa_user_text nvarchar(255) CONSTRAINT DF_fa_user_text DEFAULT '',
   fa_actor bigint NOT NULL CONSTRAINT DF_fa_actor DEFAULT 0,
@@ -995,8 +986,7 @@ CREATE TABLE /*_*/recentchanges (
   rc_title nvarchar(255) NOT NULL default '',
 
   -- as in revision...
-  rc_comment nvarchar(255) NOT NULL default '',
-  rc_comment_id bigint NOT NULL CONSTRAINT DF_rc_comment_id DEFAULT 0 CONSTRAINT FK_rc_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  rc_comment_id bigint NOT NULL CONSTRAINT FK_rc_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
   rc_minor bit NOT NULL default 0,
 
   -- Edits by user accounts with the 'bot' rights key are
@@ -1189,12 +1179,8 @@ CREATE TABLE /*_*/logging (
   log_title nvarchar(255) NOT NULL default '',
   log_page int NULL, -- NOT an FK, logging entries are inserted for deleted pages which still reference the deleted page ids
 
-  -- Freeform text. Interpreted as edit history comments.
-  log_comment nvarchar(255) NOT NULL default '',
-
   -- Key to comment_id. Comment summarizing the change.
-  -- ("DEFAULT 0" is temporary, signaling that log_comment should be used)
-  log_comment_id bigint NOT NULL CONSTRAINT DF_log_comment_id DEFAULT 0 CONSTRAINT FK_log_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  log_comment_id bigint NOT NULL CONSTRAINT FK_log_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
 
   -- miscellaneous parameters:
   -- LF separated list (old system) or serialized PHP array (new system)
@@ -1358,8 +1344,7 @@ CREATE TABLE /*_*/protected_titles (
   pt_namespace int NOT NULL,
   pt_title nvarchar(255) NOT NULL,
   pt_user int REFERENCES /*_*/mwuser(user_id) ON DELETE SET NULL,
-  pt_reason nvarchar(255) CONSTRAINT DF_pt_reason DEFAULT '',
-  pt_reason_id bigint NOT NULL CONSTRAINT DF_pt_reason_id DEFAULT 0 CONSTRAINT FK_pt_reason_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
+  pt_reason_id bigint NOT NULL CONSTRAINT FK_pt_reason_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
   pt_timestamp varchar(14) NOT NULL,
   pt_expiry varchar(14) NOT NULL,
   pt_create_perm nvarchar(60) NOT NULL,
diff --git a/maintenance/oracle/archives/patch-drop-comment-fields.sql b/maintenance/oracle/archives/patch-drop-comment-fields.sql
new file mode 100644 (file)
index 0000000..ea3c641
--- /dev/null
@@ -0,0 +1,30 @@
+--
+-- patch-drop-comment-fields.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+ALTER TABLE &mw_prefix.archive DROP COLUMN ar_comment;
+ALTER TABLE &mw_prefix.archive MODIFY ar_comment_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.ipblocks DROP COLUMN ipb_reason;
+ALTER TABLE &mw_prefix.ipblocks MODIFY ipb_reason_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.image DROP COLUMN img_description;
+ALTER TABLE &mw_prefix.image MODIFY img_description_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.oldimage DROP COLUMN oi_description;
+ALTER TABLE &mw_prefix.oldimage MODIFY oi_description_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.filearchive DROP COLUMN fa_deleted_reason;
+ALTER TABLE &mw_prefix.filearchive MODIFY fa_deleted_reason_id DEFAULT NULL,
+ALTER TABLE &mw_prefix.filearchive DROP COLUMN fa_description;
+ALTER TABLE &mw_prefix.filearchive MODIFY fa_description_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.recentchanges DROP COLUMN rc_comment;
+ALTER TABLE &mw_prefix.recentchanges MODIFY rc_comment_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.logging DROP COLUMN log_comment;
+ALTER TABLE &mw_prefix.logging MODIFY log_comment_id DEFAULT NULL;
+
+ALTER TABLE &mw_prefix.protected_titles DROP COLUMN pt_reason;
+ALTER TABLE &mw_prefix.protected_titles MODIFY pt_reason_id DEFAULT NULL;
index 2c20fff..7a8160f 100644 (file)
@@ -248,8 +248,7 @@ CREATE TABLE &mw_prefix.archive (
   ar_id          NUMBER NOT NULL,
   ar_namespace   NUMBER    DEFAULT 0 NOT NULL,
   ar_title       VARCHAR2(255)         NOT NULL,
-  ar_comment     VARCHAR2(255),
-  ar_comment_id  NUMBER DEFAULT 0 NOT NULL,
+  ar_comment_id  NUMBER NOT NULL,
   ar_user        NUMBER          DEFAULT 0 NOT NULL,
   ar_user_text   VARCHAR2(255)         NULL,
   ar_actor       NUMBER          DEFAULT 0 NOT NULL,
@@ -497,8 +496,7 @@ CREATE TABLE &mw_prefix.ipblocks (
   ipb_by                NUMBER      DEFAULT 0 NOT NULL,
   ipb_by_text           VARCHAR2(255)      NULL,
   ipb_by_actor          NUMBER      DEFAULT 0 NOT NULL,
-  ipb_reason            VARCHAR2(255)      NULL,
-  ipb_reason_id         NUMBER DEFAULT 0 NOT NULL,
+  ipb_reason_id         NUMBER NOT NULL,
   ipb_timestamp         TIMESTAMP(6) WITH TIME ZONE  NOT NULL,
   ipb_auto              CHAR(1)         DEFAULT '0' NOT NULL,
   ipb_anon_only         CHAR(1)         DEFAULT '0' NOT NULL,
@@ -549,8 +547,7 @@ CREATE TABLE &mw_prefix.image (
   img_media_type   VARCHAR2(32),
   img_major_mime   VARCHAR2(32) DEFAULT 'unknown',
   img_minor_mime   VARCHAR2(100) DEFAULT 'unknown',
-  img_description  VARCHAR2(255),
-  img_description_id  NUMBER DEFAULT 0 NOT NULL,
+  img_description_id  NUMBER NOT NULL,
   img_user         NUMBER       DEFAULT 0 NOT NULL,
   img_user_text    VARCHAR2(255)      NULL,
   img_actor        NUMBER       DEFAULT 0 NOT NULL,
@@ -574,8 +571,7 @@ CREATE TABLE &mw_prefix.oldimage (
   oi_width         NUMBER      DEFAULT 0 NOT NULL,
   oi_height        NUMBER      DEFAULT 0 NOT NULL,
   oi_bits          NUMBER      DEFAULT 0 NOT NULL,
-  oi_description   VARCHAR2(255),
-  oi_description_id  NUMBER DEFAULT 0 NOT NULL,
+  oi_description_id  NUMBER NOT NULL,
   oi_user          NUMBER          DEFAULT 0 NOT NULL,
   oi_user_text     VARCHAR2(255)         NULL,
   oi_actor         NUMBER          DEFAULT 0 NOT NULL,
@@ -606,8 +602,7 @@ CREATE TABLE &mw_prefix.filearchive (
   fa_storage_key        VARCHAR2(64),
   fa_deleted_user       NUMBER          DEFAULT 0 NOT NULL,
   fa_deleted_timestamp  TIMESTAMP(6) WITH TIME ZONE  NOT NULL,
-  fa_deleted_reason     CLOB,
-  fa_deleted_reason_id  NUMBER DEFAULT 0 NOT NULL,
+  fa_deleted_reason_id  NUMBER NOT NULL,
   fa_size               NUMBER     DEFAULT 0 NOT NULL,
   fa_width              NUMBER     DEFAULT 0 NOT NULL,
   fa_height             NUMBER     DEFAULT 0 NOT NULL,
@@ -616,8 +611,7 @@ CREATE TABLE &mw_prefix.filearchive (
   fa_media_type         VARCHAR2(32) DEFAULT NULL,
   fa_major_mime         VARCHAR2(32) DEFAULT 'unknown',
   fa_minor_mime         VARCHAR2(100) DEFAULT 'unknown',
-  fa_description        VARCHAR2(255),
-  fa_description_id     NUMBER DEFAULT 0 NOT NULL,
+  fa_description_id     NUMBER NOT NULL,
   fa_user               NUMBER          DEFAULT 0 NOT NULL,
   fa_user_text          VARCHAR2(255)         NULL,
   fa_actor              NUMBER          DEFAULT 0 NOT NULL,
@@ -687,8 +681,7 @@ CREATE TABLE &mw_prefix.recentchanges (
   rc_actor           NUMBER          DEFAULT 0 NOT NULL,
   rc_namespace       NUMBER     DEFAULT 0 NOT NULL,
   rc_title           VARCHAR2(255)         NOT NULL,
-  rc_comment         VARCHAR2(255),
-  rc_comment_id      NUMBER DEFAULT 0 NOT NULL,
+  rc_comment_id      NUMBER NOT NULL,
   rc_minor           CHAR(1)         DEFAULT '0' NOT NULL,
   rc_bot             CHAR(1)         DEFAULT '0' NOT NULL,
   rc_new             CHAR(1)         DEFAULT '0' NOT NULL,
@@ -788,8 +781,7 @@ CREATE TABLE &mw_prefix.logging (
   log_namespace   NUMBER     DEFAULT 0 NOT NULL,
   log_title       VARCHAR2(255)         NOT NULL,
   log_page                             NUMBER,
-  log_comment     VARCHAR2(255),
-  log_comment_id  NUMBER DEFAULT 0 NOT NULL,
+  log_comment_id  NUMBER NOT NULL,
   log_params      CLOB,
   log_deleted     CHAR(1)      DEFAULT '0' NOT NULL
 );
@@ -906,8 +898,7 @@ CREATE TABLE &mw_prefix.protected_titles (
   pt_namespace   NUMBER           DEFAULT 0 NOT NULL,
   pt_title       VARCHAR2(255)    NOT NULL,
   pt_user        NUMBER                  NOT NULL,
-  pt_reason      VARCHAR2(255),
-  pt_reason_id   NUMBER DEFAULT 0 NOT NULL,
+  pt_reason_id   NUMBER NOT NULL,
   pt_timestamp   TIMESTAMP(6) WITH TIME ZONE  NOT NULL,
   pt_expiry      VARCHAR2(14) NOT NULL,
   pt_create_perm VARCHAR2(60) NOT NULL
index b6858c5..87fb396 100644 (file)
@@ -243,8 +243,7 @@ CREATE TABLE archive (
   ar_page_id        INTEGER          NULL,
   ar_parent_id      INTEGER          NULL,
   ar_sha1           TEXT         NOT NULL DEFAULT '',
-  ar_comment        TEXT         NOT NULL DEFAULT '',
-  ar_comment_id     INTEGER      NOT NULL DEFAULT 0,
+  ar_comment_id     INTEGER      NOT NULL,
   ar_user           INTEGER      NOT NULL DEFAULT 0 REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
   ar_user_text      TEXT         NOT NULL DEFAULT '',
   ar_actor          INTEGER      NOT NULL DEFAULT 0,
@@ -408,8 +407,7 @@ CREATE TABLE ipblocks (
   ipb_by                INTEGER      NOT NULL  DEFAULT 0 REFERENCES mwuser(user_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
   ipb_by_text           TEXT         NOT NULL  DEFAULT '',
   ipb_by_actor          INTEGER      NOT NULL  DEFAULT 0,
-  ipb_reason            TEXT         NOT NULL  DEFAULT '',
-  ipb_reason_id         INTEGER      NOT NULL  DEFAULT 0,
+  ipb_reason_id         INTEGER      NOT NULL,
   ipb_timestamp         TIMESTAMPTZ  NOT NULL,
   ipb_auto              SMALLINT     NOT NULL  DEFAULT 0,
   ipb_anon_only         SMALLINT     NOT NULL  DEFAULT 0,
@@ -449,8 +447,7 @@ CREATE TABLE image (
   img_media_type   TEXT,
   img_major_mime   TEXT                DEFAULT 'unknown',
   img_minor_mime   TEXT                DEFAULT 'unknown',
-  img_description  TEXT      NOT NULL  DEFAULT '',
-  img_description_id INTEGER NOT NULL  DEFAULT 0,
+  img_description_id INTEGER NOT NULL,
   img_user         INTEGER   NOT NULL  DEFAULT 0 REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
   img_user_text    TEXT      NOT NULL  DEFAULT '',
   img_actor        INTEGER   NOT NULL  DEFAULT 0,
@@ -468,8 +465,7 @@ CREATE TABLE oldimage (
   oi_width         INTEGER      NOT NULL,
   oi_height        INTEGER      NOT NULL,
   oi_bits          SMALLINT         NULL,
-  oi_description   TEXT         NOT NULL DEFAULT '',
-  oi_description_id INTEGER     NOT NULL DEFAULT 0,
+  oi_description_id INTEGER     NOT NULL,
   oi_user          INTEGER      NOT NULL DEFAULT 0  REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
   oi_user_text     TEXT         NOT NULL DEFAULT '',
   oi_actor         INTEGER      NOT NULL DEFAULT 0,
@@ -496,8 +492,7 @@ CREATE TABLE filearchive (
   fa_storage_key        TEXT,
   fa_deleted_user       INTEGER          NULL  REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
   fa_deleted_timestamp  TIMESTAMPTZ  NOT NULL,
-  fa_deleted_reason     TEXT         NOT NULL  DEFAULT '',
-  fa_deleted_reason_id  INTEGER      NOT NULL  DEFAULT 0,
+  fa_deleted_reason_id  INTEGER      NOT NULL,
   fa_size               INTEGER      NOT NULL,
   fa_width              INTEGER      NOT NULL,
   fa_height             INTEGER      NOT NULL,
@@ -506,8 +501,7 @@ CREATE TABLE filearchive (
   fa_media_type         TEXT,
   fa_major_mime         TEXT                   DEFAULT 'unknown',
   fa_minor_mime         TEXT                   DEFAULT 'unknown',
-  fa_description        TEXT         NOT NULL DEFAULT '',
-  fa_description_id     INTEGER      NOT NULL DEFAULT 0,
+  fa_description_id     INTEGER      NOT NULL,
   fa_user               INTEGER      NOT NULL DEFAULT 0 REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
   fa_user_text          TEXT         NOT NULL DEFAULT '',
   fa_actor              INTEGER      NOT NULL DEFAULT 0,
@@ -559,8 +553,7 @@ CREATE TABLE recentchanges (
   rc_actor           INTEGER      NOT NULL  DEFAULT 0,
   rc_namespace       SMALLINT     NOT NULL,
   rc_title           TEXT         NOT NULL,
-  rc_comment         TEXT         NOT NULL  DEFAULT '',
-  rc_comment_id      INTEGER      NOT NULL  DEFAULT 0,
+  rc_comment_id      INTEGER      NOT NULL,
   rc_minor           SMALLINT     NOT NULL  DEFAULT 0,
   rc_bot             SMALLINT     NOT NULL  DEFAULT 0,
   rc_new             SMALLINT     NOT NULL  DEFAULT 0,
@@ -657,8 +650,7 @@ CREATE TABLE logging (
   log_actor       INTEGER      NOT NULL DEFAULT 0,
   log_namespace   SMALLINT     NOT NULL,
   log_title       TEXT         NOT NULL,
-  log_comment     TEXT         NOT NULL DEFAULT '',
-  log_comment_id  INTEGER      NOT NULL DEFAULT 0,
+  log_comment_id  INTEGER      NOT NULL,
   log_params      TEXT,
   log_deleted     SMALLINT     NOT NULL DEFAULT 0,
   log_user_text   TEXT         NOT NULL DEFAULT '',
@@ -767,8 +759,7 @@ CREATE TABLE protected_titles (
   pt_namespace   SMALLINT    NOT NULL,
   pt_title       TEXT        NOT NULL,
   pt_user        INTEGER         NULL  REFERENCES mwuser(user_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
-  pt_reason      TEXT        NOT NULL DEFAULT '',
-  pt_reason_id   INTEGER     NOT NULL DEFAULT 0,
+  pt_reason_id   INTEGER     NOT NULL,
   pt_timestamp   TIMESTAMPTZ NOT NULL,
   pt_expiry      TIMESTAMPTZ     NULL,
   pt_create_perm TEXT        NOT NULL DEFAULT '',
diff --git a/maintenance/sqlite/archives/patch-archive-drop-ar_comment.sql b/maintenance/sqlite/archives/patch-archive-drop-ar_comment.sql
new file mode 100644 (file)
index 0000000..b412ebb
--- /dev/null
@@ -0,0 +1,47 @@
+--
+-- patch-archive-drop-ar_comment.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/archive_tmp;
+CREATE TABLE /*_*/archive_tmp (
+  ar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  ar_namespace int NOT NULL default 0,
+  ar_title varchar(255) binary NOT NULL default '',
+  ar_comment_id bigint unsigned NOT NULL,
+  ar_user int unsigned NOT NULL default 0,
+  ar_user_text varchar(255) binary NOT NULL DEFAULT '',
+  ar_actor bigint unsigned NOT NULL DEFAULT 0,
+  ar_timestamp binary(14) NOT NULL default '',
+  ar_minor_edit tinyint NOT NULL default 0,
+  ar_rev_id int unsigned NOT NULL,
+  ar_text_id int unsigned NOT NULL DEFAULT 0,
+  ar_deleted tinyint unsigned NOT NULL default 0,
+  ar_len int unsigned,
+  ar_page_id int unsigned,
+  ar_parent_id int unsigned default NULL,
+  ar_sha1 varbinary(32) NOT NULL default '',
+  ar_content_model varbinary(32) DEFAULT NULL,
+  ar_content_format varbinary(64) DEFAULT NULL
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/archive_tmp (
+       ar_id, ar_namespace, ar_title, ar_comment_id, ar_user, ar_user_text, ar_actor,
+       ar_timestamp, ar_minor_edit, ar_rev_id, ar_text_id, ar_deleted,
+       ar_len, ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format
+  ) SELECT
+       ar_id, ar_namespace, ar_title, ar_comment_id, ar_user, ar_user_text, ar_actor,
+       ar_timestamp, ar_minor_edit, ar_rev_id, ar_text_id, ar_deleted,
+       ar_len, ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format
+  FROM /*_*/archive;
+
+DROP TABLE /*_*/archive;
+ALTER TABLE /*_*/archive_tmp RENAME TO /*_*/archive;
+CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
+CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
+CREATE INDEX /*i*/ar_actor_timestamp ON /*_*/archive (ar_actor,ar_timestamp);
+CREATE UNIQUE INDEX /*i*/ar_revid_uniq ON /*_*/archive (ar_rev_id);
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-filearchive-drop-fa_description.sql b/maintenance/sqlite/archives/patch-filearchive-drop-fa_description.sql
new file mode 100644 (file)
index 0000000..5880031
--- /dev/null
@@ -0,0 +1,58 @@
+--
+-- patch-filearchive-drop-fa_description.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+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_id bigint unsigned NOT NULL,
+  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_id bigint unsigned NOT NULL,
+  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_id,
+       fa_size, fa_width, fa_height, fa_metadata, fa_bits,
+       fa_media_type, fa_major_mime, fa_minor_mime, fa_description_id,
+       fa_user, fa_user_text, fa_actor, 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_id,
+       fa_size, fa_width, fa_height, fa_metadata, fa_bits,
+       fa_media_type, fa_major_mime, fa_minor_mime, fa_description_id,
+       fa_user, fa_user_text, fa_actor, 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_actor_timestamp ON /*_*/filearchive (fa_actor,fa_timestamp);
+CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-image-drop-img_description.sql b/maintenance/sqlite/archives/patch-image-drop-img_description.sql
new file mode 100644 (file)
index 0000000..c7bb90c
--- /dev/null
@@ -0,0 +1,47 @@
+--
+-- patch-image-drop-img_description.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/image_tmp;
+CREATE TABLE /*_*/image_tmp (
+  img_name varchar(255) binary NOT NULL default '' PRIMARY KEY,
+  img_size int unsigned NOT NULL default 0,
+  img_width int NOT NULL default 0,
+  img_height int NOT NULL default 0,
+  img_metadata mediumblob NOT NULL,
+  img_bits int NOT NULL default 0,
+  img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
+  img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
+  img_minor_mime varbinary(100) NOT NULL default "unknown",
+  img_description_id bigint unsigned NOT NULL,
+  img_user int unsigned NOT NULL default 0,
+  img_user_text varchar(255) binary NOT NULL DEFAULT '',
+  img_actor bigint unsigned NOT NULL DEFAULT 0,
+  img_timestamp varbinary(14) NOT NULL default '',
+  img_sha1 varbinary(32) NOT NULL default ''
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/image_tmp (
+       img_name, img_size, img_width, img_height, img_metadata, img_bits,
+       img_media_type, img_major_mime, img_minor_mime, img_description_id, img_user,
+       img_user_text, img_actor, img_timestamp, img_sha1
+  ) SELECT
+       img_name, img_size, img_width, img_height, img_metadata, img_bits,
+       img_media_type, img_major_mime, img_minor_mime, img_description_id, img_user,
+       img_user_text, img_actor, img_timestamp, img_sha1
+  FROM /*_*/image;
+
+DROP TABLE /*_*/image;
+ALTER TABLE /*_*/image_tmp RENAME TO /*_*/image;
+CREATE INDEX /*i*/img_user_timestamp ON /*_*/image (img_user,img_timestamp);
+CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
+CREATE INDEX /*i*/img_actor_timestamp ON /*_*/image (img_actor,img_timestamp);
+CREATE INDEX /*i*/img_size ON /*_*/image (img_size);
+CREATE INDEX /*i*/img_timestamp ON /*_*/image (img_timestamp);
+CREATE INDEX /*i*/img_sha1 ON /*_*/image (img_sha1(10));
+CREATE INDEX /*i*/img_media_mime ON /*_*/image (img_media_type,img_major_mime,img_minor_mime);
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-ipblocks-drop-ipb_reason.sql b/maintenance/sqlite/archives/patch-ipblocks-drop-ipb_reason.sql
new file mode 100644 (file)
index 0000000..de5faa0
--- /dev/null
@@ -0,0 +1,53 @@
+--
+-- patch-ipblocks-drop-ipb_reason.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS ipblocks_tmp;
+CREATE TABLE /*_*/ipblocks_tmp (
+  ipb_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  ipb_address tinyblob NOT NULL,
+  ipb_user int unsigned NOT NULL default 0,
+  ipb_by int unsigned NOT NULL default 0,
+  ipb_by_text varchar(255) binary NOT NULL default '',
+  ipb_by_actor bigint unsigned NOT NULL DEFAULT 0,
+  ipb_reason_id bigint unsigned NOT NULL,
+  ipb_timestamp binary(14) NOT NULL default '',
+  ipb_auto bool NOT NULL default 0,
+  ipb_anon_only bool NOT NULL default 0,
+  ipb_create_account bool NOT NULL default 1,
+  ipb_enable_autoblock bool NOT NULL default '1',
+  ipb_expiry varbinary(14) NOT NULL default '',
+  ipb_range_start tinyblob NOT NULL,
+  ipb_range_end tinyblob NOT NULL,
+  ipb_deleted bool NOT NULL default 0,
+  ipb_block_email bool NOT NULL default 0,
+  ipb_allow_usertalk bool NOT NULL default 0,
+  ipb_parent_block_id int default NULL,
+  ipb_sitewide bool NOT NULL default 1
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/ipblocks_tmp (
+       ipb_id, ipb_address, ipb_user, ipb_by, ipb_by_text, ipb_by_actor, ipb_reason_id,
+       ipb_timestamp, ipb_auto, ipb_anon_only, ipb_create_account,
+       ipb_enable_autoblock, ipb_expiry, ipb_range_start, ipb_range_end,
+       ipb_deleted, ipb_block_email, ipb_allow_usertalk, ipb_parent_block_id, ipb_sitewide
+  ) SELECT
+       ipb_id, ipb_address, ipb_user, ipb_by, ipb_by_text, ipb_by_actor, ipb_reason_id,
+       ipb_timestamp, ipb_auto, ipb_anon_only, ipb_create_account,
+       ipb_enable_autoblock, ipb_expiry, ipb_range_start, ipb_range_end,
+       ipb_deleted, ipb_block_email, ipb_allow_usertalk, ipb_parent_block_id, ipb_sitewide
+  FROM /*_*/ipblocks;
+
+DROP TABLE /*_*/ipblocks;
+ALTER TABLE /*_*/ipblocks_tmp RENAME TO /*_*/ipblocks;
+CREATE UNIQUE INDEX /*i*/ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
+CREATE INDEX /*i*/ipb_user ON /*_*/ipblocks (ipb_user);
+CREATE INDEX /*i*/ipb_range ON /*_*/ipblocks (ipb_range_start(8), ipb_range_end(8));
+CREATE INDEX /*i*/ipb_timestamp ON /*_*/ipblocks (ipb_timestamp);
+CREATE INDEX /*i*/ipb_expiry ON /*_*/ipblocks (ipb_expiry);
+CREATE INDEX /*i*/ipb_parent_block_id ON /*_*/ipblocks (ipb_parent_block_id);
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-logging-drop-log_comment.sql b/maintenance/sqlite/archives/patch-logging-drop-log_comment.sql
new file mode 100644 (file)
index 0000000..0b53324
--- /dev/null
@@ -0,0 +1,47 @@
+--
+-- patch-logging-drop-log_comment.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/logging_tmp;
+CREATE TABLE /*_*/logging_tmp (
+  log_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  log_type varbinary(32) NOT NULL default '',
+  log_action varbinary(32) NOT NULL default '',
+  log_timestamp binary(14) NOT NULL default '19700101000000',
+  log_user int unsigned NOT NULL default 0,
+  log_user_text varchar(255) binary NOT NULL default '',
+  log_actor bigint unsigned NOT NULL DEFAULT 0,
+  log_namespace int NOT NULL default 0,
+  log_title varchar(255) binary NOT NULL default '',
+  log_page int unsigned NULL,
+  log_comment_id bigint unsigned NOT NULL,
+  log_params blob NOT NULL,
+  log_deleted tinyint unsigned NOT NULL default 0
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/logging_tmp (
+       log_id, log_type, log_action, log_timestamp, log_user, log_user_text, log_actor,
+       log_namespace, log_title, log_page, log_comment_id, log_params, log_deleted
+  ) SELECT
+       log_id, log_type, log_action, log_timestamp, log_user, log_user_text, log_actor,
+       log_namespace, log_title, log_page, log_comment_id, log_params, log_deleted
+  FROM /*_*/logging;
+
+DROP TABLE /*_*/logging;
+ALTER TABLE /*_*/logging_tmp RENAME TO /*_*/logging;
+CREATE INDEX /*i*/type_time ON /*_*/logging (log_type, log_timestamp);
+CREATE INDEX /*i*/user_time ON /*_*/logging (log_user, log_timestamp);
+CREATE INDEX /*i*/actor_time ON /*_*/logging (log_actor, log_timestamp);
+CREATE INDEX /*i*/page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
+CREATE INDEX /*i*/times ON /*_*/logging (log_timestamp);
+CREATE INDEX /*i*/log_user_type_time ON /*_*/logging (log_user, log_type, log_timestamp);
+CREATE INDEX /*i*/log_actor_type_time ON /*_*/logging (log_actor, log_type, log_timestamp);
+CREATE INDEX /*i*/log_page_id_time ON /*_*/logging (log_page,log_timestamp);
+CREATE INDEX /*i*/log_type_action ON /*_*/logging (log_type, log_action, log_timestamp);
+CREATE INDEX /*i*/log_user_text_type_time ON /*_*/logging (log_user_text, log_type, log_timestamp);
+CREATE INDEX /*i*/log_user_text_time ON /*_*/logging (log_user_text, log_timestamp);
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-oldimage-drop-oi_description.sql b/maintenance/sqlite/archives/patch-oldimage-drop-oi_description.sql
new file mode 100644 (file)
index 0000000..1c67cb0
--- /dev/null
@@ -0,0 +1,47 @@
+--
+-- patch-oldimage-drop-oi_description.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/oldimage_tmp;
+CREATE TABLE /*_*/oldimage_tmp (
+  oi_name varchar(255) binary NOT NULL default '',
+  oi_archive_name varchar(255) binary NOT NULL default '',
+  oi_size int unsigned NOT NULL default 0,
+  oi_width int NOT NULL default 0,
+  oi_height int NOT NULL default 0,
+  oi_bits int NOT NULL default 0,
+  oi_description_id bigint unsigned NOT NULL,
+  oi_user int unsigned NOT NULL default 0,
+  oi_user_text varchar(255) binary NOT NULL DEFAULT '',
+  oi_actor bigint unsigned NOT NULL DEFAULT 0,
+  oi_timestamp binary(14) NOT NULL default '',
+  oi_metadata mediumblob NOT NULL,
+  oi_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
+  oi_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
+  oi_minor_mime varbinary(100) NOT NULL default "unknown",
+  oi_deleted tinyint unsigned NOT NULL default 0,
+  oi_sha1 varbinary(32) NOT NULL default ''
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/oldimage_tmp (
+       oi_name, oi_archive_name, oi_size, oi_width, oi_height, oi_bits,
+       oi_description_id, oi_user, oi_user_text, oi_actor, oi_timestamp, oi_metadata,
+       oi_media_type, oi_major_mime, oi_minor_mime, oi_deleted, oi_sha1
+  ) SELECT
+       oi_name, oi_archive_name, oi_size, oi_width, oi_height, oi_bits,
+       oi_description_id, oi_user, oi_user_text, oi_actor, oi_timestamp, oi_metadata,
+       oi_media_type, oi_major_mime, oi_minor_mime, oi_deleted, oi_sha1
+  FROM /*_*/oldimage;
+
+DROP TABLE /*_*/oldimage;
+ALTER TABLE /*_*/oldimage_tmp RENAME TO /*_*/oldimage;
+CREATE INDEX /*i*/oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
+CREATE INDEX /*i*/oi_actor_timestamp ON /*_*/oldimage (oi_actor,oi_timestamp);
+CREATE INDEX /*i*/oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
+CREATE INDEX /*i*/oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
+CREATE INDEX /*i*/oi_sha1 ON /*_*/oldimage (oi_sha1(10));
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-protected_titles-drop-pt_reason.sql b/maintenance/sqlite/archives/patch-protected_titles-drop-pt_reason.sql
new file mode 100644 (file)
index 0000000..731b9d8
--- /dev/null
@@ -0,0 +1,30 @@
+--
+-- patch-protected_titles-drop-pt_reason.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/protected_titles_tmp;
+CREATE TABLE /*_*/protected_titles_tmp (
+  pt_namespace int NOT NULL,
+  pt_title varchar(255) binary NOT NULL,
+  pt_user int unsigned NOT NULL,
+  pt_reason_id bigint unsigned NOT NULL,
+  pt_timestamp binary(14) NOT NULL,
+  pt_expiry varbinary(14) NOT NULL default '',
+  pt_create_perm varbinary(60) NOT NULL,
+  PRIMARY KEY (pt_namespace,pt_title)
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/protected_titles_tmp (
+       pt_namespace, pt_title, pt_user, pt_reason_id, pt_timestamp, pt_expiry, pt_create_perm
+  ) SELECT
+       pt_namespace, pt_title, pt_user, pt_reason_id, pt_timestamp, pt_expiry, pt_create_perm
+  FROM /*_*/protected_titles;
+
+DROP TABLE /*_*/protected_titles;
+ALTER TABLE /*_*/protected_titles_tmp RENAME TO /*_*/protected_titles;
+CREATE INDEX /*i*/pt_timestamp ON /*_*/protected_titles (pt_timestamp);
+
+COMMIT;
diff --git a/maintenance/sqlite/archives/patch-recentchanges-drop-rc_comment.sql b/maintenance/sqlite/archives/patch-recentchanges-drop-rc_comment.sql
new file mode 100644 (file)
index 0000000..5ce52da
--- /dev/null
@@ -0,0 +1,63 @@
+--
+-- patch-recentchanges-drop-rc_comment.sql
+--
+-- T166732. Drop old xx_comment fields, and defaults from xx_comment_id fields.
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/recentchanges_tmp;
+CREATE TABLE /*_*/recentchanges_tmp (
+  rc_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  rc_timestamp varbinary(14) NOT NULL default '',
+  rc_user int unsigned NOT NULL default 0,
+  rc_user_text varchar(255) binary NOT NULL DEFAULT '',
+  rc_actor bigint unsigned NOT NULL DEFAULT 0,
+  rc_namespace int NOT NULL default 0,
+  rc_title varchar(255) binary NOT NULL default '',
+  rc_comment_id bigint unsigned NOT NULL,
+  rc_minor tinyint unsigned NOT NULL default 0,
+  rc_bot tinyint unsigned NOT NULL default 0,
+  rc_new tinyint unsigned NOT NULL default 0,
+  rc_cur_id int unsigned NOT NULL default 0,
+  rc_this_oldid int unsigned NOT NULL default 0,
+  rc_last_oldid int unsigned NOT NULL default 0,
+  rc_type tinyint unsigned NOT NULL default 0,
+  rc_source varchar(16) binary not null default '',
+  rc_patrolled tinyint unsigned NOT NULL default 0,
+  rc_ip varbinary(40) NOT NULL default '',
+  rc_old_len int,
+  rc_new_len int,
+  rc_deleted tinyint unsigned NOT NULL default 0,
+  rc_logid int unsigned NOT NULL default 0,
+  rc_log_type varbinary(255) NULL default NULL,
+  rc_log_action varbinary(255) NULL default NULL,
+  rc_params blob NULL
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/recentchanges_tmp (
+       rc_id, rc_timestamp, rc_user, rc_user_text, rc_actor, rc_namespace, rc_title,
+       rc_comment_id, rc_minor, rc_bot, rc_new, rc_cur_id, rc_this_oldid, rc_last_oldid,
+       rc_type, rc_source, rc_patrolled, rc_ip, rc_old_len, rc_new_len, rc_deleted,
+       rc_logid, rc_log_type, rc_log_action, rc_params
+  ) SELECT
+       rc_id, rc_timestamp, rc_user, rc_user_text, rc_actor, rc_namespace, rc_title,
+       rc_comment_id, rc_minor, rc_bot, rc_new, rc_cur_id, rc_this_oldid, rc_last_oldid,
+       rc_type, rc_source, rc_patrolled, rc_ip, rc_old_len, rc_new_len, rc_deleted,
+       rc_logid, rc_log_type, rc_log_action, rc_params
+  FROM /*_*/recentchanges;
+
+DROP TABLE /*_*/recentchanges;
+ALTER TABLE /*_*/recentchanges_tmp RENAME TO /*_*/recentchanges;
+CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp);
+CREATE INDEX /*i*/rc_namespace_title_timestamp ON /*_*/recentchanges (rc_namespace, rc_title, rc_timestamp);
+CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id);
+CREATE INDEX /*i*/new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
+CREATE INDEX /*i*/rc_ip ON /*_*/recentchanges (rc_ip);
+CREATE INDEX /*i*/rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text);
+CREATE INDEX /*i*/rc_ns_actor ON /*_*/recentchanges (rc_namespace, rc_actor);
+CREATE INDEX /*i*/rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp);
+CREATE INDEX /*i*/rc_actor ON /*_*/recentchanges (rc_actor, rc_timestamp);
+CREATE INDEX /*i*/rc_name_type_patrolled_timestamp ON /*_*/recentchanges (rc_namespace, rc_type, rc_patrolled, rc_timestamp);
+CREATE INDEX /*i*/rc_this_oldid ON /*_*/recentchanges (rc_this_oldid);
+
+COMMIT;
index 83ba4e2..dac222f 100644 (file)
@@ -593,8 +593,7 @@ CREATE TABLE /*_*/archive (
   ar_title varchar(255) binary NOT NULL default '',
 
   -- Basic revision stuff...
-  ar_comment varbinary(767) NOT NULL default '', -- Deprecated in favor of ar_comment_id
-  ar_comment_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ar_comment should be used)
+  ar_comment_id bigint unsigned NOT NULL,
   ar_user int unsigned NOT NULL default 0, -- Deprecated in favor of ar_actor
   ar_user_text varchar(255) binary NOT NULL DEFAULT '', -- Deprecated in favor of ar_actor
   ar_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ar_user/ar_user_text should be used)
@@ -1044,12 +1043,8 @@ CREATE TABLE /*_*/ipblocks (
   -- Actor who made the block.
   ipb_by_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ipb_by/ipb_by_text should be used)
 
-  -- Text comment made by blocker. Deprecated in favor of ipb_reason_id
-  ipb_reason varbinary(767) NOT NULL default '',
-
   -- Key to comment_id. Text comment made by blocker.
-  -- ("DEFAULT 0" is temporary, signaling that ipb_reason should be used)
-  ipb_reason_id bigint unsigned NOT NULL DEFAULT 0,
+  ipb_reason_id bigint unsigned NOT NULL,
 
   -- Creation (or refresh) date in standard YMDHMS form.
   -- IP blocks expire automatically.
@@ -1180,10 +1175,7 @@ CREATE TABLE /*_*/image (
 
   -- Description field as entered by the uploader.
   -- This is displayed in image upload history and logs.
-  -- Deprecated in favor of img_description_id.
-  img_description varbinary(767) NOT NULL default '',
-
-  img_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that img_description should be used)
+  img_description_id bigint unsigned NOT NULL,
 
   -- user_id and user_name of uploader.
   -- Deprecated in favor of img_actor.
@@ -1233,8 +1225,7 @@ CREATE TABLE /*_*/oldimage (
   oi_width int NOT NULL default 0,
   oi_height int NOT NULL default 0,
   oi_bits int NOT NULL default 0,
-  oi_description varbinary(767) NOT NULL default '', -- Deprecated.
-  oi_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that oi_description should be used)
+  oi_description_id bigint unsigned NOT NULL,
   oi_user int unsigned NOT NULL default 0, -- Deprecated in favor of oi_actor
   oi_user_text varchar(255) binary NOT NULL DEFAULT '', -- Deprecated in favor of oi_actor
   oi_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that oi_user/oi_user_text should be used)
@@ -1284,8 +1275,7 @@ CREATE TABLE /*_*/filearchive (
   -- Deletion information, if this file is deleted.
   fa_deleted_user int,
   fa_deleted_timestamp binary(14) default '',
-  fa_deleted_reason varbinary(767) default '', -- Deprecated
-  fa_deleted_reason_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that fa_deleted_reason should be used)
+  fa_deleted_reason_id bigint unsigned NOT NULL,
 
   -- Duped fields from image
   fa_size int unsigned default 0,
@@ -1296,8 +1286,7 @@ CREATE TABLE /*_*/filearchive (
   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 '', -- Deprecated
-  fa_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that fa_description should be used)
+  fa_description_id bigint unsigned NOT NULL,
   fa_user int unsigned default 0, -- Deprecated in favor of fa_actor
   fa_user_text varchar(255) binary DEFAULT '', -- Deprecated in favor of fa_actor
   fa_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that fa_user/fa_user_text should be used)
@@ -1398,8 +1387,7 @@ CREATE TABLE /*_*/recentchanges (
   rc_title varchar(255) binary NOT NULL default '',
 
   -- as in revision...
-  rc_comment varbinary(767) NOT NULL default '', -- Deprecated.
-  rc_comment_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that rc_comment should be used)
+  rc_comment_id bigint unsigned NOT NULL,
   rc_minor tinyint unsigned NOT NULL default 0,
 
   -- Edits by user accounts with the 'bot' rights key are
@@ -1622,13 +1610,8 @@ CREATE TABLE /*_*/logging (
   log_title varchar(255) binary NOT NULL default '',
   log_page int unsigned NULL,
 
-  -- Freeform text. Interpreted as edit history comments.
-  -- Deprecated in favor of log_comment_id.
-  log_comment varbinary(767) NOT NULL default '',
-
   -- Key to comment_id. Comment summarizing the change.
-  -- ("DEFAULT 0" is temporary, signaling that log_comment should be used)
-  log_comment_id bigint unsigned NOT NULL DEFAULT 0,
+  log_comment_id bigint unsigned NOT NULL,
 
   -- miscellaneous parameters:
   -- LF separated list (old system) or serialized PHP array (new system)
@@ -1805,8 +1788,7 @@ CREATE TABLE /*_*/protected_titles (
   pt_namespace int NOT NULL,
   pt_title varchar(255) binary NOT NULL,
   pt_user int unsigned NOT NULL,
-  pt_reason varbinary(767) default '', -- Deprecated.
-  pt_reason_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that pt_reason should be used)
+  pt_reason_id bigint unsigned NOT NULL,
   pt_timestamp binary(14) NOT NULL,
   pt_expiry varbinary(14) NOT NULL default '',
   pt_create_perm varbinary(60) NOT NULL,
index b6c7b03..0e6a3ee 100644 (file)
@@ -1199,7 +1199,7 @@ class ParserTestRunner {
         * @return array
         */
        private function listTables() {
-               global $wgCommentTableSchemaMigrationStage, $wgActorTableSchemaMigrationStage;
+               global $wgActorTableSchemaMigrationStage;
 
                $tables = [ 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'ip_changes', 'text', 'pagelinks', 'imagelinks',
@@ -1209,14 +1209,9 @@ class ParserTestRunner {
                        'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
                        'archive', 'user_groups', 'page_props', 'category',
                        'slots', 'content', 'slot_roles', 'content_models',
+                       'comment', 'revision_comment_temp',
                ];
 
-               if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
-                       // The new tables for comments are in use
-                       $tables[] = 'comment';
-                       $tables[] = 'revision_comment_temp';
-               }
-
                if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
                        // The new tables for actors are in use
                        $tables[] = 'actor';
index b761d29..15c70bc 100644 (file)
@@ -571,10 +571,8 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
        public static function provideInsertRoundTrip() {
                $db = wfGetDB( DB_REPLICA ); // for timestamps
 
-               $ipbfields = [
-               ];
-               $revfields = [
-               ];
+               $comment = MediaWikiServices::getInstance()->getCommentStore()
+                       ->createComment( wfGetDB( DB_MASTER ), '' );
 
                return [
                        'recentchanges' => [ 'recentchanges', 'rc_user', 'rc_id', [
@@ -584,12 +582,14 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
                                'rc_this_oldid' => 42,
                                'rc_last_oldid' => 41,
                                'rc_source' => 'test',
+                               'rc_comment_id' => $comment->id,
                        ] ],
                        'ipblocks' => [ 'ipblocks', 'ipb_by', 'ipb_id', [
                                'ipb_range_start' => '',
                                'ipb_range_end' => '',
                                'ipb_timestamp' => $db->timestamp(),
                                'ipb_expiry' => $db->getInfinity(),
+                               'ipb_reason_id' => $comment->id,
                        ] ],
                        'revision' => [ 'revision', 'rev_user', 'rev_id', [
                                'rev_page' => 42,
index 4360343..78c5bf3 100644 (file)
@@ -18,6 +18,17 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                'comment',
        ];
 
+       protected function getSchemaOverrides( IMaintainableDatabase $db ) {
+               return [
+                       'scripts' => [
+                               __DIR__ . '/CommentStoreTest.sql',
+                       ],
+                       'drop' => [],
+                       'create' => [ 'commentstore1', 'commentstore2', 'commentstore2_temp' ],
+                       'alter' => [],
+               ];
+       }
+
        /**
         * Create a store for a particular stage
         * @param int $stage
@@ -25,6 +36,16 @@ class CommentStoreTest extends MediaWikiLangTestCase {
         */
        protected function makeStore( $stage ) {
                $store = new CommentStore( MediaWikiServices::getInstance()->getContentLanguage(), $stage );
+
+               TestingAccessWrapper::newFromObject( $store )->tempTables += [ 'cs2_comment' => [
+                       'table' => 'commentstore2_temp',
+                       'pk' => 'cs2t_id',
+                       'field' => 'cs2t_comment_id',
+                       'joinPK' => 'cs2_id',
+                       'stage' => MIGRATION_OLD,
+                       'deprecatedIn' => null,
+               ] ];
+
                return $store;
        }
 
@@ -38,6 +59,16 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                $this->hideDeprecated( 'CommentStore::newKey' );
                $store = CommentStore::newKey( $key );
                TestingAccessWrapper::newFromObject( $store )->stage = $stage;
+
+               TestingAccessWrapper::newFromObject( $store )->tempTables += [ 'cs2_comment' => [
+                       'table' => 'commentstore2_temp',
+                       'pk' => 'cs2t_id',
+                       'field' => 'cs2t_comment_id',
+                       'joinPK' => 'cs2_id',
+                       'stage' => MIGRATION_OLD,
+                       'deprecatedIn' => null,
+               ] ];
+
                return $store;
        }
 
@@ -360,12 +391,13 @@ class CommentStoreTest extends MediaWikiLangTestCase {
         * @param string $table
         * @param string $key
         * @param string $pk
-        * @param string $extraFields
         * @param string|Message $comment
         * @param array|null $data
         * @param array $expect
         */
-       public function testInsertRoundTrip( $table, $key, $pk, $extraFields, $comment, $data, $expect ) {
+       public function testInsertRoundTrip( $table, $key, $pk, $comment, $data, $expect ) {
+               static $id = 1;
+
                $expectOld = [
                        'text' => $expect['text'],
                        'message' => new RawMessage( '$1', [ $expect['text'] ] ),
@@ -381,12 +413,8 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                ];
 
                foreach ( $stages as $writeStage => $possibleReadStages ) {
-                       if ( $key === 'ipb_reason' ) {
-                               $extraFields['ipb_address'] = __CLASS__ . "#$writeStage";
-                       }
-
                        $wstore = $this->makeStore( $writeStage );
-                       $usesTemp = $key === 'rev_comment';
+                       $usesTemp = $key === 'cs2_comment';
 
                        if ( $usesTemp ) {
                                list( $fields, $callback ) = $wstore->insertWithTempTable(
@@ -407,8 +435,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                                $this->assertArrayNotHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
                        }
 
-                       $this->db->insert( $table, $extraFields + $fields, __METHOD__ );
-                       $id = $this->db->insertId();
+                       $this->db->insert( $table, [ $pk => ++$id ] + $fields, __METHOD__ );
                        if ( $usesTemp ) {
                                $callback( $id );
                        }
@@ -452,14 +479,15 @@ class CommentStoreTest extends MediaWikiLangTestCase {
         * @param string $table
         * @param string $key
         * @param string $pk
-        * @param string $extraFields
         * @param string|Message $comment
         * @param array|null $data
         * @param array $expect
         */
        public function testInsertRoundTrip_withKeyConstruction(
-               $table, $key, $pk, $extraFields, $comment, $data, $expect
+               $table, $key, $pk, $comment, $data, $expect
        ) {
+               static $id = 1000;
+
                $expectOld = [
                        'text' => $expect['text'],
                        'message' => new RawMessage( '$1', [ $expect['text'] ] ),
@@ -475,12 +503,8 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                ];
 
                foreach ( $stages as $writeStage => $possibleReadStages ) {
-                       if ( $key === 'ipb_reason' ) {
-                               $extraFields['ipb_address'] = __CLASS__ . "#$writeStage";
-                       }
-
                        $wstore = $this->makeStoreWithKey( $writeStage, $key );
-                       $usesTemp = $key === 'rev_comment';
+                       $usesTemp = $key === 'cs2_comment';
 
                        if ( $usesTemp ) {
                                list( $fields, $callback ) = $wstore->insertWithTempTable(
@@ -501,8 +525,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                                $this->assertArrayNotHasKey( "{$key}_id", $fields, "new field, stage=$writeStage" );
                        }
 
-                       $this->db->insert( $table, $extraFields + $fields, __METHOD__ );
-                       $id = $this->db->insertId();
+                       $this->db->insert( $table, [ $pk => ++$id ] + $fields, __METHOD__ );
                        if ( $usesTemp ) {
                                $callback( $id );
                        }
@@ -547,60 +570,48 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                $msgComment = new Message( 'parentheses', [ 'message comment' ] );
                $textCommentMsg = new RawMessage( '$1', [ 'text comment' ] );
                $nestedMsgComment = new Message( [ 'parentheses', 'rawmessage' ], [ new Message( 'mainpage' ) ] );
-               $ipbfields = [
-                       'ipb_range_start' => '',
-                       'ipb_range_end' => '',
-                       'ipb_timestamp' => $db->timestamp(),
-                       'ipb_expiry' => $db->getInfinity(),
-               ];
-               $revfields = [
-                       'rev_page' => 42,
-                       'rev_text_id' => 42,
-                       'rev_len' => 0,
-                       'rev_timestamp' => $db->timestamp(),
-               ];
                $comStoreComment = new CommentStoreComment(
                        null, 'comment store comment', null, [ 'foo' => 'bar' ]
                );
 
                return [
                        'Simple table, text comment' => [
-                               'ipblocks', 'ipb_reason', 'ipb_id', $ipbfields, 'text comment', null, [
+                               'commentstore1', 'cs1_comment', 'cs1_id', 'text comment', null, [
                                        'text' => 'text comment',
                                        'message' => $textCommentMsg,
                                        'data' => null,
                                ]
                        ],
                        'Simple table, text comment with data' => [
-                               'ipblocks', 'ipb_reason', 'ipb_id', $ipbfields, 'text comment', [ 'message' => 42 ], [
+                               'commentstore1', 'cs1_comment', 'cs1_id', 'text comment', [ 'message' => 42 ], [
                                        'text' => 'text comment',
                                        'message' => $textCommentMsg,
                                        'data' => [ 'message' => 42 ],
                                ]
                        ],
                        'Simple table, message comment' => [
-                               'ipblocks', 'ipb_reason', 'ipb_id', $ipbfields, $msgComment, null, [
+                               'commentstore1', 'cs1_comment', 'cs1_id', $msgComment, null, [
                                        'text' => '(message comment)',
                                        'message' => $msgComment,
                                        'data' => null,
                                ]
                        ],
                        'Simple table, message comment with data' => [
-                               'ipblocks', 'ipb_reason', 'ipb_id', $ipbfields, $msgComment, [ 'message' => 42 ], [
+                               'commentstore1', 'cs1_comment', 'cs1_id', $msgComment, [ 'message' => 42 ], [
                                        'text' => '(message comment)',
                                        'message' => $msgComment,
                                        'data' => [ 'message' => 42 ],
                                ]
                        ],
                        'Simple table, nested message comment' => [
-                               'ipblocks', 'ipb_reason', 'ipb_id', $ipbfields, $nestedMsgComment, null, [
+                               'commentstore1', 'cs1_comment', 'cs1_id', $nestedMsgComment, null, [
                                        'text' => '(Main Page)',
                                        'message' => $nestedMsgComment,
                                        'data' => null,
                                ]
                        ],
                        'Simple table, CommentStoreComment' => [
-                               'ipblocks', 'ipb_reason', 'ipb_id', $ipbfields, clone $comStoreComment, [ 'baz' => 'baz' ], [
+                               'commentstore1', 'cs1_comment', 'cs1_id', clone $comStoreComment, [ 'baz' => 'baz' ], [
                                        'text' => 'comment store comment',
                                        'message' => $comStoreComment->message,
                                        'data' => [ 'foo' => 'bar' ],
@@ -608,42 +619,42 @@ class CommentStoreTest extends MediaWikiLangTestCase {
                        ],
 
                        'Revision, text comment' => [
-                               'revision', 'rev_comment', 'rev_id', $revfields, 'text comment', null, [
+                               'commentstore2', 'cs2_comment', 'cs2_id', 'text comment', null, [
                                        'text' => 'text comment',
                                        'message' => $textCommentMsg,
                                        'data' => null,
                                ]
                        ],
                        'Revision, text comment with data' => [
-                               'revision', 'rev_comment', 'rev_id', $revfields, 'text comment', [ 'message' => 42 ], [
+                               'commentstore2', 'cs2_comment', 'cs2_id', 'text comment', [ 'message' => 42 ], [
                                        'text' => 'text comment',
                                        'message' => $textCommentMsg,
                                        'data' => [ 'message' => 42 ],
                                ]
                        ],
                        'Revision, message comment' => [
-                               'revision', 'rev_comment', 'rev_id', $revfields, $msgComment, null, [
+                               'commentstore2', 'cs2_comment', 'cs2_id', $msgComment, null, [
                                        'text' => '(message comment)',
                                        'message' => $msgComment,
                                        'data' => null,
                                ]
                        ],
                        'Revision, message comment with data' => [
-                               'revision', 'rev_comment', 'rev_id', $revfields, $msgComment, [ 'message' => 42 ], [
+                               'commentstore2', 'cs2_comment', 'cs2_id', $msgComment, [ 'message' => 42 ], [
                                        'text' => '(message comment)',
                                        'message' => $msgComment,
                                        'data' => [ 'message' => 42 ],
                                ]
                        ],
                        'Revision, nested message comment' => [
-                               'revision', 'rev_comment', 'rev_id', $revfields, $nestedMsgComment, null, [
+                               'commentstore2', 'cs2_comment', 'cs2_id', $nestedMsgComment, null, [
                                        'text' => '(Main Page)',
                                        'message' => $nestedMsgComment,
                                        'data' => null,
                                ]
                        ],
                        'Revision, CommentStoreComment' => [
-                               'revision', 'rev_comment', 'rev_id', $revfields, clone $comStoreComment, [ 'baz' => 'baz' ], [
+                               'commentstore2', 'cs2_comment', 'cs2_id', clone $comStoreComment, [ 'baz' => 'baz' ], [
                                        'text' => 'comment store comment',
                                        'message' => $comStoreComment->message,
                                        'data' => [ 'foo' => 'bar' ],
diff --git a/tests/phpunit/includes/CommentStoreTest.sql b/tests/phpunit/includes/CommentStoreTest.sql
new file mode 100644 (file)
index 0000000..f95781d
--- /dev/null
@@ -0,0 +1,17 @@
+-- These are carefully crafted to work in all five supported databases
+
+CREATE TABLE /*_*/commentstore1 (
+  cs1_id integer not null,
+  cs1_comment varchar(200),
+  cs1_comment_id integer
+);
+
+CREATE TABLE /*_*/commentstore2 (
+  cs2_id integer not null,
+  cs2_comment varchar(200)
+);
+
+CREATE TABLE /*_*/commentstore2_temp (
+  cs2t_id integer not null,
+  cs2t_comment_id integer
+);
index 7188cf5..9f1c69c 100644 (file)
@@ -52,23 +52,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                return $fields;
        }
 
-       protected function getOldCommentQueryFields( $prefix ) {
-               return [
-                       "{$prefix}_comment_text" => "{$prefix}_comment",
-                       "{$prefix}_comment_data" => 'NULL',
-                       "{$prefix}_comment_cid" => 'NULL',
-               ];
-       }
-
-       protected function getCompatCommentQueryFields( $prefix ) {
-               return [
-                       "{$prefix}_comment_text"
-                               => "COALESCE( comment_{$prefix}_comment.comment_text, {$prefix}_comment )",
-                       "{$prefix}_comment_data" => "comment_{$prefix}_comment.comment_data",
-                       "{$prefix}_comment_cid" => "comment_{$prefix}_comment.comment_id",
-               ];
-       }
-
        protected function getNewCommentQueryFields( $prefix ) {
                return [
                        "{$prefix}_comment_text" => "comment_{$prefix}_comment.comment_text",
@@ -106,19 +89,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                ];
        }
 
-       protected function getCompatCommentJoins( $prefix ) {
-               return [
-                       "temp_{$prefix}_comment" => [
-                               "LEFT JOIN",
-                               "temp_{$prefix}_comment.revcomment_{$prefix} = {$prefix}_id",
-                       ],
-                       "comment_{$prefix}_comment" => [
-                               "LEFT JOIN",
-                               "comment_{$prefix}_comment.comment_id = temp_{$prefix}_comment.revcomment_comment_id",
-                       ],
-               ];
-       }
-
        protected function getTextQueryFields() {
                return [
                        'old_text',
@@ -154,7 +124,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'MCR, comment, actor' => [
                        [
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [
@@ -180,7 +149,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [
@@ -192,11 +160,11 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'fields' => array_merge(
                                        $this->getArchiveQueryFields( false ),
                                        $this->getNewActorQueryFields( 'ar' ),
-                                       $this->getCompatCommentQueryFields( 'ar' )
+                                       $this->getNewCommentQueryFields( 'ar' )
                                ),
                                'joins' => [
                                        'comment_ar_comment'
-                                               => [ 'LEFT JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
+                                               => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
                                        'actor_ar_user' => [ 'JOIN', 'actor_ar_user.actor_id = ar_actor' ],
                                ],
                        ]
@@ -206,7 +174,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        [
@@ -218,11 +185,11 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getArchiveQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'ar' ),
                                        $this->getOldActorQueryFields( 'ar' ),
-                                       $this->getCompatCommentQueryFields( 'ar' )
+                                       $this->getNewCommentQueryFields( 'ar' )
                                ),
                                'joins' => [
                                        'comment_ar_comment'
-                                               => [ 'LEFT JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
+                                               => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
                                ],
                        ]
                ];
@@ -230,19 +197,22 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [
                                'tables' => [
                                        'archive',
+                                       'comment_ar_comment' => 'comment',
                                ],
                                'fields' => array_merge(
                                        $this->getArchiveQueryFields( true ),
                                        $this->getOldActorQueryFields( 'ar' ),
-                                       $this->getOldCommentQueryFields( 'ar' )
+                                       $this->getNewCommentQueryFields( 'ar' )
                                ),
-                               'joins' => [],
+                               'joins' => [
+                                       'comment_ar_comment'
+                                               => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
+                               ],
                        ]
                ];
        }
@@ -253,7 +223,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [ 'page', 'user' ],
@@ -298,7 +267,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                        ],
                        [ 'page', 'user' ],
@@ -317,7 +285,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
                                        $this->getNewActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
                                        [
@@ -329,9 +297,11 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                                'user_id = actor_rev_user.actor_user',
                                                        ]
                                                ],
+                                               'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                               'comment_rev_comment'
+                                                       => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                        ],
-                                       $this->getNewActorJoins( 'rev' ),
-                                       $this->getCompatCommentJoins( 'rev' )
+                                       $this->getNewActorJoins( 'rev' )
                                ),
                        ]
                ];
@@ -340,7 +310,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                        ],
                        [ 'page', 'user' ],
@@ -359,7 +328,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
                                        $this->getNewActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
                                        [
@@ -371,9 +340,11 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                                'user_id = actor_rev_user.actor_user'
                                                        ]
                                                ],
+                                               'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                               'comment_rev_comment'
+                                                       => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                        ],
-                                       $this->getNewActorJoins( 'rev' ),
-                                       $this->getCompatCommentJoins( 'rev' )
+                                       $this->getNewActorJoins( 'rev' )
                                ),
                        ]
                ];
@@ -382,7 +353,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        [],
@@ -396,11 +366,13 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getRevisionQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getOldActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
-                       'joins' => array_merge(
-                               $this->getCompatCommentJoins( 'rev' )
-                       ),
+                               'joins' => [
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                               ],
                        ]
                ];
                yield 'MCR write-both/read-old, page, user' => [
@@ -408,7 +380,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        [ 'page', 'user' ],
@@ -426,7 +397,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getUserQueryFields(),
                                        $this->getPageQueryFields(),
                                        $this->getOldActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
                                        [
@@ -438,8 +409,10 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                                'user_id = rev_user'
                                                        ]
                                                ],
-                                       ],
-                                       $this->getCompatCommentJoins( 'rev' )
+                                               'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                               'comment_rev_comment'
+                                                       => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                                       ]
                                ),
                        ]
                ];
@@ -447,42 +420,55 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [],
                        [
-                               'tables' => [ 'revision' ],
+                               'tables' => [
+                                       'revision',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
-                               'joins' => [],
+                               'joins' => [
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                               ],
                        ]
                ];
                yield 'pre-MCR, page, user' => [
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'page', 'user' ],
                        [
-                               'tables' => [ 'revision', 'page', 'user' ],
+                               'tables' => [
+                                       'revision', 'page', 'user',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
                                        'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ]
                ];
@@ -490,38 +476,51 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [],
                        [
-                               'tables' => [ 'revision' ],
+                               'tables' => [
+                                       'revision',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
-                               'joins' => [],
+                               'joins' => [
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                               ],
                        ],
                ];
                yield 'pre-MCR, no model, page' => [
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'page' ],
                        [
-                               'tables' => [ 'revision', 'page' ],
+                               'tables' => [
+                                       'revision', 'page',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getPageQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ], ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -529,20 +528,26 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'user' ],
                        [
-                               'tables' => [ 'revision', 'user' ],
+                               'tables' => [
+                                       'revision', 'user',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getUserQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -550,20 +555,26 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'text' ],
                        [
-                               'tables' => [ 'revision', 'text' ],
+                               'tables' => [
+                                       'revision', 'text',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getTextQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -571,13 +582,14 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'text', 'page', 'user' ],
                        [
                                'tables' => [
-                                       'revision', 'page', 'user', 'text'
+                                       'revision', 'page', 'user', 'text',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
                                ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
@@ -585,7 +597,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getUserQueryFields(),
                                        $this->getTextQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'page' => [
@@ -603,6 +615,9 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                'INNER JOIN',
                                                [ 'rev_text_id=old_id' ],
                                        ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -833,7 +848,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'with model, comment, and actor' => [
                        [
                                'wgContentHandlerUseDB' => true,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        'fields' => array_merge(
@@ -853,7 +867,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                ],
                                $this->getContentHandlerQueryFields( 'rev' ),
                                [
-                                       'rev_comment_old' => 'rev_comment',
                                        'rev_comment_pk' => 'rev_id',
                                ]
                        ),
@@ -861,7 +874,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'no mode, no comment, no actor' => [
                        [
                                'wgContentHandlerUseDB' => false,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        'fields' => array_merge(
@@ -878,8 +890,8 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'rev_len',
                                        'rev_parent_id',
                                        'rev_sha1',
-                               ],
-                               $this->getOldCommentQueryFields( 'rev' )
+                                       'rev_comment_pk' => 'rev_id',
+                               ]
                        ),
                ];
        }
@@ -888,7 +900,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'with model, comment, and actor' => [
                        [
                                'wgContentHandlerUseDB' => true,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        'fields' => array_merge(
@@ -909,7 +920,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                ],
                                $this->getContentHandlerQueryFields( 'ar' ),
                                [
-                                       'ar_comment_old' => 'ar_comment',
                                        'ar_comment_id' => 'ar_comment_id',
                                ]
                        ),
@@ -917,7 +927,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'no mode, no comment, no actor' => [
                        [
                                'wgContentHandlerUseDB' => false,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
                                'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        'fields' => array_merge(
@@ -935,8 +944,8 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'ar_len',
                                        'ar_parent_id',
                                        'ar_sha1',
-                               ],
-                               $this->getOldCommentQueryFields( 'ar' )
+                                       'ar_comment_id' => 'ar_comment_id',
+                               ]
                        ),
                ];
        }
index 68632f3..018df48 100644 (file)
@@ -80,7 +80,6 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase {
                $this->setMwGlobals( [
                        'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
                        'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
-                       'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                        'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                ] );
 
index 6c7b0e7..339dc30 100644 (file)
@@ -90,7 +90,6 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->setMwGlobals( [
                        'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
                        'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
-                       'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                        'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                ] );
 
index 20689d6..02a6c19 100644 (file)
@@ -281,7 +281,6 @@ class RevisionTest extends MediaWikiTestCase {
         * @covers \MediaWiki\Revision\RevisionStore::newMutableRevisionFromArray
         */
        public function testConstructFromRowWithBadPageId() {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->overrideMwServices();
                Wikimedia\suppressWarnings();
                $rev = new Revision( (object)[
@@ -602,7 +601,6 @@ class RevisionTest extends MediaWikiTestCase {
         * @covers Revision::loadFromTitle
         */
        public function testLoadFromTitle() {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->overrideMwServices();
                $title = $this->getMockTitle();
index ddc0798..90a5ed1 100644 (file)
@@ -379,33 +379,17 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
        protected function assertRecentChangeByCategorization(
                Title $pageTitle, ParserOutput $parserOutput, Title $categoryTitle, $expectedRows
        ) {
-               global $wgCommentTableSchemaMigrationStage;
-
-               if ( $wgCommentTableSchemaMigrationStage <= MIGRATION_WRITE_BOTH ) {
-                       $this->assertSelect(
-                               'recentchanges',
-                               'rc_title, rc_comment',
-                               [
-                                       'rc_type' => RC_CATEGORIZE,
-                                       'rc_namespace' => NS_CATEGORY,
-                                       'rc_title' => $categoryTitle->getDBkey()
-                               ],
-                               $expectedRows
-                       );
-               }
-               if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
-                       $this->assertSelect(
-                               [ 'recentchanges', 'comment' ],
-                               'rc_title, comment_text',
-                               [
-                                       'rc_type' => RC_CATEGORIZE,
-                                       'rc_namespace' => NS_CATEGORY,
-                                       'rc_title' => $categoryTitle->getDBkey(),
-                                       'comment_id = rc_comment_id',
-                               ],
-                               $expectedRows
-                       );
-               }
+               $this->assertSelect(
+                       [ 'recentchanges', 'comment' ],
+                       'rc_title, comment_text',
+                       [
+                               'rc_type' => RC_CATEGORIZE,
+                               'rc_namespace' => NS_CATEGORY,
+                               'rc_title' => $categoryTitle->getDBkey(),
+                               'comment_id = rc_comment_id',
+                       ],
+                       $expectedRows
+               );
        }
 
        private function runAllRelatedJobs() {
index e75b173..b183cde 100644 (file)
@@ -29,18 +29,15 @@ class DatabaseLogEntryTest extends MediaWikiTestCase {
         * @param array $selectFields
         * @param string[]|null $row
         * @param string[]|null $expectedFields
-        * @param int $commentMigration
         * @param int $actorMigration
         */
        public function testNewFromId( $id,
                array $selectFields,
                array $row = null,
                array $expectedFields = null,
-               $commentMigration,
                $actorMigration
        ) {
                $this->setMwGlobals( [
-                       'wgCommentTableSchemaMigrationStage' => $commentMigration,
                        'wgActorTableSchemaMigrationStage' => $actorMigration,
                ] );
 
@@ -71,7 +68,10 @@ class DatabaseLogEntryTest extends MediaWikiTestCase {
 
        public function provideNewFromId() {
                $oldTables = [
-                       'tables' => [ 'logging', 'user' ],
+                       'tables' => [
+                               'logging', 'user',
+                               'comment_log_comment' => 'comment',
+                       ],
                        'fields' => [
                                'log_id',
                                'log_type',
@@ -84,15 +84,18 @@ class DatabaseLogEntryTest extends MediaWikiTestCase {
                                'user_id',
                                'user_name',
                                'user_editcount',
-                               'log_comment_text' => 'log_comment',
-                               'log_comment_data' => 'NULL',
-                               'log_comment_cid' => 'NULL',
+                               'log_comment_text' => 'comment_log_comment.comment_text',
+                               'log_comment_data' => 'comment_log_comment.comment_data',
+                               'log_comment_cid' => 'comment_log_comment.comment_id',
                                'log_user' => 'log_user',
                                'log_user_text' => 'log_user_text',
                                'log_actor' => 'NULL',
                        ],
                        'options' => [],
-                       'join_conds' => [ 'user' => [ 'LEFT JOIN', 'user_id=log_user' ] ],
+                       'join_conds' => [
+                               'user' => [ 'LEFT JOIN', 'user_id=log_user' ],
+                               'comment_log_comment' => [ 'JOIN', 'comment_log_comment.comment_id = log_comment_id' ],
+                       ],
                ];
                $newTables = [
                        'tables' => [
@@ -133,7 +136,6 @@ class DatabaseLogEntryTest extends MediaWikiTestCase {
                                $oldTables + [ 'conds' => [ 'log_id' => 0 ] ],
                                null,
                                null,
-                               MIGRATION_OLD,
                                SCHEMA_COMPAT_OLD,
                        ],
                        [
@@ -146,7 +148,6 @@ class DatabaseLogEntryTest extends MediaWikiTestCase {
                                        'log_comment_data' => null,
                                ],
                                [ 'type' => 'foobarize', 'comment' => 'test!' ],
-                               MIGRATION_OLD,
                                SCHEMA_COMPAT_OLD,
                        ],
                        [
@@ -159,7 +160,6 @@ class DatabaseLogEntryTest extends MediaWikiTestCase {
                                        'log_comment_data' => null,
                                ],
                                [ 'type' => 'foobarize', 'comment' => 'test!' ],
-                               MIGRATION_NEW,
                                SCHEMA_COMPAT_NEW,
                        ],
                ];
index 26b6b52..06c0456 100644 (file)
@@ -82,7 +82,6 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase {
 
                $this->tablesUsed += $this->getMcrTablesToReset();
 
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() );
                $this->setMwGlobals(
index 298dc52..933e47d 100644 (file)
@@ -1560,89 +1560,6 @@ more stuff
                $this->assertTrue( $page->wasLoadedFrom( IDBAccessObject::READ_EXCLUSIVE ) );
        }
 
-       /**
-        * @dataProvider provideCommentMigrationOnDeletion
-        *
-        * @param int $writeStage
-        * @param int $readStage
-        */
-       public function testCommentMigrationOnDeletion( $writeStage, $readStage ) {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', $writeStage );
-               $this->overrideMwServices();
-
-               $dbr = wfGetDB( DB_REPLICA );
-
-               $page = $this->createPage(
-                       __METHOD__,
-                       "foo",
-                       CONTENT_MODEL_WIKITEXT
-               );
-               $revid = $page->getLatest();
-               if ( $writeStage > MIGRATION_OLD ) {
-                       $comment_id = $dbr->selectField(
-                               'revision_comment_temp',
-                               'revcomment_comment_id',
-                               [ 'revcomment_rev' => $revid ],
-                               __METHOD__
-                       );
-               }
-
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', $readStage );
-               $this->overrideMwServices();
-
-               $page->doDeleteArticle( "testing deletion" );
-
-               if ( $readStage > MIGRATION_OLD ) {
-                       // Didn't leave behind any 'revision_comment_temp' rows
-                       $n = $dbr->selectField(
-                               'revision_comment_temp', 'COUNT(*)', [ 'revcomment_rev' => $revid ], __METHOD__
-                       );
-                       $this->assertEquals( 0, $n, 'no entry in revision_comment_temp after deletion' );
-
-                       // Copied or upgraded the comment_id, as applicable
-                       $ar_comment_id = $dbr->selectField(
-                               'archive',
-                               'ar_comment_id',
-                               [ 'ar_rev_id' => $revid ],
-                               __METHOD__
-                       );
-                       if ( $writeStage > MIGRATION_OLD ) {
-                               $this->assertSame( $comment_id, $ar_comment_id );
-                       } else {
-                               $this->assertNotEquals( 0, $ar_comment_id );
-                       }
-               }
-
-               // Copied rev_comment, if applicable
-               if ( $readStage <= MIGRATION_WRITE_BOTH && $writeStage <= MIGRATION_WRITE_BOTH ) {
-                       $ar_comment = $dbr->selectField(
-                               'archive',
-                               'ar_comment',
-                               [ 'ar_rev_id' => $revid ],
-                               __METHOD__
-                       );
-                       $this->assertSame( 'testing', $ar_comment );
-               }
-       }
-
-       public function provideCommentMigrationOnDeletion() {
-               return [
-                       [ MIGRATION_OLD, MIGRATION_OLD ],
-                       [ MIGRATION_OLD, MIGRATION_WRITE_BOTH ],
-                       [ MIGRATION_OLD, MIGRATION_WRITE_NEW ],
-                       [ MIGRATION_WRITE_BOTH, MIGRATION_OLD ],
-                       [ MIGRATION_WRITE_BOTH, MIGRATION_WRITE_BOTH ],
-                       [ MIGRATION_WRITE_BOTH, MIGRATION_WRITE_NEW ],
-                       [ MIGRATION_WRITE_BOTH, MIGRATION_NEW ],
-                       [ MIGRATION_WRITE_NEW, MIGRATION_WRITE_BOTH ],
-                       [ MIGRATION_WRITE_NEW, MIGRATION_WRITE_NEW ],
-                       [ MIGRATION_WRITE_NEW, MIGRATION_NEW ],
-                       [ MIGRATION_NEW, MIGRATION_WRITE_BOTH ],
-                       [ MIGRATION_NEW, MIGRATION_WRITE_NEW ],
-                       [ MIGRATION_NEW, MIGRATION_NEW ],
-               ];
-       }
-
        /**
         * @covers WikiPage::updateCategoryCounts
         */
index 42569d7..b8d1383 100644 (file)
@@ -30,6 +30,9 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                $dbw = wfGetDB( DB_MASTER );
                $logs = [];
 
+               $comment = \MediaWiki\MediaWikiServices::getInstance()->getCommentStore()
+                       ->createComment( $dbw, '' );
+
                // Manual patrolling
                $logs[] = [
                        'log_type' => 'patrol',
@@ -39,6 +42,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20041223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Autopatrol #1
@@ -50,6 +54,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20051223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Block
@@ -61,6 +66,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20061223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Very old/ invalid patrol
@@ -72,6 +78,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20061223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Autopatrol #2
@@ -83,6 +90,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20071223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Autopatrol #3 old way
@@ -94,6 +102,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20081223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Manual patrol #2 old way
@@ -105,6 +114,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20091223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Autopatrol #4 very old way
@@ -116,6 +126,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20081223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                // Manual patrol #3 very old way
@@ -127,6 +138,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => $dbw->timestamp( '20091223210426' ),
                        'log_namespace' => NS_MAIN,
                        'log_title' => 'DeleteAutoPatrolLogs',
+                       'log_comment_id' => $comment->id,
                ];
 
                $dbw->insert( 'logging', $logs );