From: Brad Jorsch Date: Fri, 4 Jan 2019 18:55:11 +0000 (-0500) Subject: Mostly drop old comment schemas X-Git-Tag: 1.34.0-rc.0~2911 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=0abb9338f870824e258a7a138ad07efbaa6b3894;p=lhc%2Fweb%2Fwiklou.git Mostly drop old comment schemas 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 --- diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 57984f6bea..8105446e9f 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -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 diff --git a/includes/CommentStore.php b/includes/CommentStore.php index cba7a150d3..1a60bb7412 100644 --- a/includes/CommentStore.php +++ b/includes/CommentStore.php @@ -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; } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 31b0988b69..e6b44edd66 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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: diff --git a/includes/EditPage.php b/includes/EditPage.php index 45995646da..300c5f3147 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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', diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 8866a88bda..5aa6edf879 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -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, diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index bb8eba125f..ac4ca773a7 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -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' ); diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 9a94389f74..44ca5025dd 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -85,7 +85,7 @@ return [ 'CommentStore' => function ( MediaWikiServices $services ) : CommentStore { return new CommentStore( $services->getContentLanguage(), - $services->getMainConfig()->get( 'CommentTableSchemaMigrationStage' ) + MIGRATION_NEW ); }, diff --git a/includes/actions/McrUndoAction.php b/includes/actions/McrUndoAction.php index b60820c0c3..47bbdc0b5c 100644 --- a/includes/actions/McrUndoAction.php +++ b/includes/actions/McrUndoAction.php @@ -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', diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 878e82d032..789d7c5215 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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'; diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 43000b8b99..d64e2d7b69 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -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' ); } diff --git a/includes/installer/MssqlUpdater.php b/includes/installer/MssqlUpdater.php index 2f1c0f3039..75f389478c 100644 --- a/includes/installer/MssqlUpdater.php +++ b/includes/installer/MssqlUpdater.php @@ -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' ], ]; } diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index f7362cbf12..2e3fdba004 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -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' ], ]; } diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index e9be744555..d3a7b132a7 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -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' ], diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 7c0d3e3c74..75877a1e50 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -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 ) ); diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index 1d99b87096..17ced507a2 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -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' ], ]; } diff --git a/includes/page/Article.php b/includes/page/Article.php index 9b5e5a5366..983f06986e 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -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, diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 6217ee7e93..072c3c6385 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -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__ ); } diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index b5d31efac7..334fc73261 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -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 ] ); diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 9c8882b820..81b82d9577 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -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', diff --git a/includes/specials/SpecialEditTags.php b/includes/specials/SpecialEditTags.php index 6198a8455b..d0bfcb09bf 100644 --- a/includes/specials/SpecialEditTags.php +++ b/includes/specials/SpecialEditTags.php @@ -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, ] ) . '' . "\n" . diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 599ab31135..0234507a13 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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, ] ), diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 50f3710143..d5bb576e51 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -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, ] ) . '' . "\n" . diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index cd754ca03d..9654bb7093 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -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(), diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 3c2907b87d..6e6d90595f 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -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, ] ) . " diff --git a/maintenance/archives/patch-drop-comment-fields.sql b/maintenance/archives/patch-drop-comment-fields.sql new file mode 100644 index 0000000000..a4b248d468 --- /dev/null +++ b/maintenance/archives/patch-drop-comment-fields.sql @@ -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; diff --git a/maintenance/migrateComments.php b/maintenance/migrateComments.php index 555f2d13f0..8025df1f67 100644 --- a/maintenance/migrateComments.php +++ b/maintenance/migrateComments.php @@ -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 index 0000000000..bdc8c91e7f --- /dev/null +++ b/maintenance/mssql/archives/patch-drop-comment-fields.sql @@ -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; diff --git a/maintenance/mssql/tables.sql b/maintenance/mssql/tables.sql index 4ecc6db835..72ea69d6bc 100644 --- a/maintenance/mssql/tables.sql +++ b/maintenance/mssql/tables.sql @@ -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 index 0000000000..ea3c6410ba --- /dev/null +++ b/maintenance/oracle/archives/patch-drop-comment-fields.sql @@ -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; diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql index 2c20ffffd8..7a8160fca3 100644 --- a/maintenance/oracle/tables.sql +++ b/maintenance/oracle/tables.sql @@ -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 diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index b6858c543f..87fb3967a1 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -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 index 0000000000..b412ebbaa5 --- /dev/null +++ b/maintenance/sqlite/archives/patch-archive-drop-ar_comment.sql @@ -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 index 0000000000..58800313d3 --- /dev/null +++ b/maintenance/sqlite/archives/patch-filearchive-drop-fa_description.sql @@ -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 index 0000000000..c7bb90ce29 --- /dev/null +++ b/maintenance/sqlite/archives/patch-image-drop-img_description.sql @@ -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 index 0000000000..de5faa0761 --- /dev/null +++ b/maintenance/sqlite/archives/patch-ipblocks-drop-ipb_reason.sql @@ -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 index 0000000000..0b53324bfe --- /dev/null +++ b/maintenance/sqlite/archives/patch-logging-drop-log_comment.sql @@ -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 index 0000000000..1c67cb0f58 --- /dev/null +++ b/maintenance/sqlite/archives/patch-oldimage-drop-oi_description.sql @@ -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 index 0000000000..731b9d8144 --- /dev/null +++ b/maintenance/sqlite/archives/patch-protected_titles-drop-pt_reason.sql @@ -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 index 0000000000..5ce52da237 --- /dev/null +++ b/maintenance/sqlite/archives/patch-recentchanges-drop-rc_comment.sql @@ -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; diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 83ba4e2f1b..dac222ffcd 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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, diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index b6c7b03a6c..0e6a3eed77 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -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'; diff --git a/tests/phpunit/includes/ActorMigrationTest.php b/tests/phpunit/includes/ActorMigrationTest.php index b761d29758..15c70bce11 100644 --- a/tests/phpunit/includes/ActorMigrationTest.php +++ b/tests/phpunit/includes/ActorMigrationTest.php @@ -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, diff --git a/tests/phpunit/includes/CommentStoreTest.php b/tests/phpunit/includes/CommentStoreTest.php index 4360343981..78c5bf3a95 100644 --- a/tests/phpunit/includes/CommentStoreTest.php +++ b/tests/phpunit/includes/CommentStoreTest.php @@ -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 index 0000000000..f95781dd3e --- /dev/null +++ b/tests/phpunit/includes/CommentStoreTest.sql @@ -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 +); diff --git a/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php b/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php index 7188cf50a7..9f1c69ce97 100644 --- a/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php +++ b/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php @@ -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', + ] ), ]; } diff --git a/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php b/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php index 68632f3e68..018df48115 100644 --- a/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php +++ b/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php @@ -80,7 +80,6 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase { $this->setMwGlobals( [ 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(), 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(), - 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW, 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD, ] ); diff --git a/tests/phpunit/includes/RevisionDbTestBase.php b/tests/phpunit/includes/RevisionDbTestBase.php index 6c7b0e7d24..339dc30890 100644 --- a/tests/phpunit/includes/RevisionDbTestBase.php +++ b/tests/phpunit/includes/RevisionDbTestBase.php @@ -90,7 +90,6 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase { $this->setMwGlobals( [ 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(), 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(), - 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW, 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD, ] ); diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 20689d608b..02a6c19d1f 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -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(); diff --git a/tests/phpunit/includes/deferred/LinksUpdateTest.php b/tests/phpunit/includes/deferred/LinksUpdateTest.php index ddc0798f1a..90a5ed17ff 100644 --- a/tests/phpunit/includes/deferred/LinksUpdateTest.php +++ b/tests/phpunit/includes/deferred/LinksUpdateTest.php @@ -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() { diff --git a/tests/phpunit/includes/logging/DatabaseLogEntryTest.php b/tests/phpunit/includes/logging/DatabaseLogEntryTest.php index e75b1739d2..b183cde1d2 100644 --- a/tests/phpunit/includes/logging/DatabaseLogEntryTest.php +++ b/tests/phpunit/includes/logging/DatabaseLogEntryTest.php @@ -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, ], ]; diff --git a/tests/phpunit/includes/page/PageArchiveTestBase.php b/tests/phpunit/includes/page/PageArchiveTestBase.php index 26b6b5234d..06c0456ac7 100644 --- a/tests/phpunit/includes/page/PageArchiveTestBase.php +++ b/tests/phpunit/includes/page/PageArchiveTestBase.php @@ -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( diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index 298dc52a3c..933e47dbcd 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -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 */ diff --git a/tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php b/tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php index 42569d782d..b8d13838e9 100644 --- a/tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php +++ b/tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php @@ -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 );