From fd5a1842d2d63fd6c7dd07358757d31dba635b28 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 7 Nov 2018 14:50:27 -0500 Subject: [PATCH] Default $wgCommentTableSchemaMigrationStage to MIGRATION_NEW WRITE_NEW mode seems to be working well on Wikimedia sites. Let's change the default to MIGRATION_NEW so existing installs and Wikimedia CI will start using the new code rather than the old. This also fixes some unit tests that were broken with MIGRATION_NEW, and updates some that were forcing MIGRATION_OLD to force MIGRATION_NEW instead. Bug: T166733 Change-Id: I7bf4ad0105dd1f6cc49eba3ddcb7a51badcd5ed3 Depends-On: I30f7cdcc3875f3f7af116c1e41e88f62ab9e91d0 --- includes/DefaultSettings.php | 2 +- .../Revision/RevisionStoreDbTestBase.php | 2 +- tests/phpunit/includes/RevisionDbTestBase.php | 2 +- tests/phpunit/includes/RevisionTest.php | 15 +++++++--- .../includes/page/PageArchiveMcrTest.php | 4 +-- .../includes/page/PageArchivePreMcrTest.php | 4 +-- .../includes/page/PageArchiveTestBase.php | 4 ++- .../includes/page/WikiPageDbTestBase.php | 28 +++++++++++-------- 8 files changed, 37 insertions(+), 24 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5175543e22..54b775deee 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -8989,7 +8989,7 @@ $wgInterwikiPrefixDisplayTypes = []; * @since 1.30 * @var int One of the MIGRATION_* constants */ -$wgCommentTableSchemaMigrationStage = MIGRATION_OLD; +$wgCommentTableSchemaMigrationStage = MIGRATION_NEW; /** * RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables). diff --git a/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php b/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php index 0d6a439dc3..fcd5016df0 100644 --- a/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php +++ b/tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php @@ -78,7 +78,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase { $this->setMwGlobals( [ 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(), 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(), - 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW, 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD, ] ); diff --git a/tests/phpunit/includes/RevisionDbTestBase.php b/tests/phpunit/includes/RevisionDbTestBase.php index e5e5551e9f..cfff088eed 100644 --- a/tests/phpunit/includes/RevisionDbTestBase.php +++ b/tests/phpunit/includes/RevisionDbTestBase.php @@ -90,7 +90,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase { $this->setMwGlobals( [ 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(), 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(), - 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD, + 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW, 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD, ] ); diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index c053104d6f..04f0793d3a 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -281,10 +281,14 @@ class RevisionTest extends MediaWikiTestCase { * @covers \MediaWiki\Revision\RevisionStore::newMutableRevisionFromArray */ public function testConstructFromRowWithBadPageId() { - $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD ); + $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW ); $this->overrideMwServices(); Wikimedia\suppressWarnings(); - $rev = new Revision( (object)[ 'rev_page' => 77777777 ] ); + $rev = new Revision( (object)[ + 'rev_page' => 77777777, + 'rev_comment_text' => '', + 'rev_comment_data' => null, + ] ); $this->assertSame( 77777777, $rev->getPage() ); Wikimedia\restoreWarnings(); } @@ -597,7 +601,7 @@ class RevisionTest extends MediaWikiTestCase { * @covers Revision::loadFromTitle */ public function testLoadFromTitle() { - $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD ); + $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW ); $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD ); $this->overrideMwServices(); $title = $this->getMockTitle(); @@ -634,7 +638,10 @@ class RevisionTest extends MediaWikiTestCase { $db->expects( $this->once() ) ->method( 'selectRow' ) ->with( - $this->equalTo( [ 'revision', 'page', 'user' ] ), + $this->equalTo( [ + 'revision', 'page', 'user', + 'temp_rev_comment' => 'revision_comment_temp', 'comment_rev_comment' => 'comment', + ] ), // We don't really care about the fields are they come from the selectField methods $this->isType( 'array' ), $this->equalTo( $conditions ), diff --git a/tests/phpunit/includes/page/PageArchiveMcrTest.php b/tests/phpunit/includes/page/PageArchiveMcrTest.php index 1e16097884..ba4b2e22f8 100644 --- a/tests/phpunit/includes/page/PageArchiveMcrTest.php +++ b/tests/phpunit/includes/page/PageArchiveMcrTest.php @@ -52,7 +52,7 @@ class PageArchiveMcrTest extends PageArchiveTestBase { 'ar_page_id' => strval( $this->ipRev->getPageId() ), 'ar_comment_text' => 'just a test', 'ar_comment_data' => null, - 'ar_comment_cid' => null, + 'ar_comment_cid' => '2', 'ts_tags' => null, 'ar_id' => '2', 'ar_namespace' => '0', @@ -72,7 +72,7 @@ class PageArchiveMcrTest extends PageArchiveTestBase { 'ar_page_id' => strval( $this->firstRev->getPageId() ), 'ar_comment_text' => 'testing', 'ar_comment_data' => null, - 'ar_comment_cid' => null, + 'ar_comment_cid' => '1', 'ts_tags' => null, 'ar_id' => '1', 'ar_namespace' => '0', diff --git a/tests/phpunit/includes/page/PageArchivePreMcrTest.php b/tests/phpunit/includes/page/PageArchivePreMcrTest.php index 4df4ee1f1c..f8d4ef9bf1 100644 --- a/tests/phpunit/includes/page/PageArchivePreMcrTest.php +++ b/tests/phpunit/includes/page/PageArchivePreMcrTest.php @@ -54,7 +54,7 @@ class PageArchivePreMcrTest extends PageArchiveTestBase { 'ar_page_id' => strval( $this->ipRev->getPageId() ), 'ar_comment_text' => 'just a test', 'ar_comment_data' => null, - 'ar_comment_cid' => null, + 'ar_comment_cid' => '2', 'ar_content_format' => null, 'ar_content_model' => null, 'ts_tags' => null, @@ -79,7 +79,7 @@ class PageArchivePreMcrTest extends PageArchiveTestBase { 'ar_page_id' => strval( $this->firstRev->getPageId() ), 'ar_comment_text' => 'testing', 'ar_comment_data' => null, - 'ar_comment_cid' => null, + 'ar_comment_cid' => '1', 'ar_content_format' => null, 'ar_content_model' => null, 'ts_tags' => null, diff --git a/tests/phpunit/includes/page/PageArchiveTestBase.php b/tests/phpunit/includes/page/PageArchiveTestBase.php index ade8efd5c3..26b6b5234d 100644 --- a/tests/phpunit/includes/page/PageArchiveTestBase.php +++ b/tests/phpunit/includes/page/PageArchiveTestBase.php @@ -43,12 +43,14 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase { [ 'page', 'revision', + 'revision_comment_temp', 'ip_changes', 'text', 'archive', 'recentchanges', 'logging', 'page_props', + 'comment', ] ); } @@ -80,7 +82,7 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase { $this->tablesUsed += $this->getMcrTablesToReset(); - $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD ); + $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW ); $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD ); $this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() ); $this->setMwGlobals( diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index fee45838b5..439bd38104 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -463,12 +463,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { ); $logId = $status->getValue(); $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' ); + $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' ); $this->assertSelect( - [ 'logging' ] + $actorQuery['tables'], /* table */ + [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */ [ 'log_type', 'log_action', - 'log_comment', + 'log_comment' => $commentQuery['fields']['log_comment_text'], 'log_user' => $actorQuery['fields']['log_user'], 'log_user_text' => $actorQuery['fields']['log_user_text'], 'log_namespace', @@ -485,7 +486,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { $page->getTitle()->getDBkey(), ] ], [], - $actorQuery['joins'] + $actorQuery['joins'] + $commentQuery['joins'] ); } @@ -512,12 +513,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { ); $logId = $status->getValue(); $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' ); + $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' ); $this->assertSelect( - [ 'logging' ] + $actorQuery['tables'], /* table */ + [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */ [ 'log_type', 'log_action', - 'log_comment', + 'log_comment' => $commentQuery['fields']['log_comment_text'], 'log_user' => $actorQuery['fields']['log_user'], 'log_user_text' => $actorQuery['fields']['log_user_text'], 'log_namespace', @@ -534,7 +536,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { $page->getTitle()->getDBkey(), ] ], [], - $actorQuery['joins'] + $actorQuery['joins'] + $commentQuery['joins'] ); } @@ -563,12 +565,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { ); $logId = $status->getValue(); $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' ); + $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' ); $this->assertSelect( - [ 'logging' ] + $actorQuery['tables'], /* table */ + [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */ [ 'log_type', 'log_action', - 'log_comment', + 'log_comment' => $commentQuery['fields']['log_comment_text'], 'log_user' => $actorQuery['fields']['log_user'], 'log_user_text' => $actorQuery['fields']['log_user_text'], 'log_namespace', @@ -585,7 +588,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { $page->getTitle()->getDBkey(), ] ], [], - $actorQuery['joins'] + $actorQuery['joins'] + $commentQuery['joins'] ); $this->assertNull( @@ -2266,10 +2269,11 @@ more stuff // Make sure the log entry looks good // log_params is not checked here $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' ); + $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' ); $this->assertSelect( - [ 'logging' ] + $actorQuery['tables'], + [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], [ - 'log_comment', + 'log_comment' => $commentQuery['fields']['log_comment_text'], 'log_user' => $actorQuery['fields']['log_user'], 'log_user_text' => $actorQuery['fields']['log_user_text'], 'log_namespace', @@ -2284,7 +2288,7 @@ more stuff $page->getTitle()->getDBkey(), ] ], [], - $actorQuery['joins'] + $actorQuery['joins'] + $commentQuery['joins'] ); } -- 2.20.1