Default $wgCommentTableSchemaMigrationStage to MIGRATION_NEW
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 7 Nov 2018 19:50:27 +0000 (14:50 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 28 Nov 2018 18:59:19 +0000 (13:59 -0500)
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
tests/phpunit/includes/Revision/RevisionStoreDbTestBase.php
tests/phpunit/includes/RevisionDbTestBase.php
tests/phpunit/includes/RevisionTest.php
tests/phpunit/includes/page/PageArchiveMcrTest.php
tests/phpunit/includes/page/PageArchivePreMcrTest.php
tests/phpunit/includes/page/PageArchiveTestBase.php
tests/phpunit/includes/page/WikiPageDbTestBase.php

index 5175543..54b775d 100644 (file)
@@ -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).
index 0d6a439..fcd5016 100644 (file)
@@ -78,7 +78,7 @@ abstract class RevisionStoreDbTestBase extends MediaWikiTestCase {
                $this->setMwGlobals( [
                        'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
                        'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
-                       'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
+                       'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                        'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                ] );
 
index e5e5551..cfff088 100644 (file)
@@ -90,7 +90,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->setMwGlobals( [
                        'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
                        'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
-                       'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
+                       'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
                        'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                ] );
 
index c053104..04f0793 100644 (file)
@@ -281,10 +281,14 @@ class RevisionTest extends MediaWikiTestCase {
         * @covers \MediaWiki\Revision\RevisionStore::newMutableRevisionFromArray
         */
        public function testConstructFromRowWithBadPageId() {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->overrideMwServices();
                Wikimedia\suppressWarnings();
-               $rev = new Revision( (object)[ 'rev_page' => 77777777 ] );
+               $rev = new Revision( (object)[
+                       'rev_page' => 77777777,
+                       'rev_comment_text' => '',
+                       'rev_comment_data' => null,
+               ] );
                $this->assertSame( 77777777, $rev->getPage() );
                Wikimedia\restoreWarnings();
        }
@@ -597,7 +601,7 @@ class RevisionTest extends MediaWikiTestCase {
         * @covers Revision::loadFromTitle
         */
        public function testLoadFromTitle() {
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->overrideMwServices();
                $title = $this->getMockTitle();
@@ -634,7 +638,10 @@ class RevisionTest extends MediaWikiTestCase {
                $db->expects( $this->once() )
                        ->method( 'selectRow' )
                        ->with(
-                               $this->equalTo( [ 'revision', 'page', 'user' ] ),
+                               $this->equalTo( [
+                                       'revision', 'page', 'user',
+                                       'temp_rev_comment' => 'revision_comment_temp', 'comment_rev_comment' => 'comment',
+                               ] ),
                                // We don't really care about the fields are they come from the selectField methods
                                $this->isType( 'array' ),
                                $this->equalTo( $conditions ),
index 1e16097..ba4b2e2 100644 (file)
@@ -52,7 +52,7 @@ class PageArchiveMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->ipRev->getPageId() ),
                                'ar_comment_text' => 'just a test',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '2',
                                'ts_tags' => null,
                                'ar_id' => '2',
                                'ar_namespace' => '0',
@@ -72,7 +72,7 @@ class PageArchiveMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->firstRev->getPageId() ),
                                'ar_comment_text' => 'testing',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '1',
                                'ts_tags' => null,
                                'ar_id' => '1',
                                'ar_namespace' => '0',
index 4df4ee1..f8d4ef9 100644 (file)
@@ -54,7 +54,7 @@ class PageArchivePreMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->ipRev->getPageId() ),
                                'ar_comment_text' => 'just a test',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '2',
                                'ar_content_format' => null,
                                'ar_content_model' => null,
                                'ts_tags' => null,
@@ -79,7 +79,7 @@ class PageArchivePreMcrTest extends PageArchiveTestBase {
                                'ar_page_id' => strval( $this->firstRev->getPageId() ),
                                'ar_comment_text' => 'testing',
                                'ar_comment_data' => null,
-                               'ar_comment_cid' => null,
+                               'ar_comment_cid' => '1',
                                'ar_content_format' => null,
                                'ar_content_model' => null,
                                'ts_tags' => null,
index ade8efd..26b6b52 100644 (file)
@@ -43,12 +43,14 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase {
                        [
                                'page',
                                'revision',
+                               'revision_comment_temp',
                                'ip_changes',
                                'text',
                                'archive',
                                'recentchanges',
                                'logging',
                                'page_props',
+                               'comment',
                        ]
                );
        }
@@ -80,7 +82,7 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase {
 
                $this->tablesUsed += $this->getMcrTablesToReset();
 
-               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', MIGRATION_NEW );
                $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() );
                $this->setMwGlobals(
index fee4583..439bd38 100644 (file)
@@ -463,12 +463,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                );
                $logId = $status->getValue();
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'], /* table */
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
                        [
                                'log_type',
                                'log_action',
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -485,7 +486,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
        }
 
@@ -512,12 +513,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                );
                $logId = $status->getValue();
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'], /* table */
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
                        [
                                'log_type',
                                'log_action',
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -534,7 +536,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
        }
 
@@ -563,12 +565,13 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                );
                $logId = $status->getValue();
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'], /* table */
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
                        [
                                'log_type',
                                'log_action',
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -585,7 +588,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase {
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
 
                $this->assertNull(
@@ -2266,10 +2269,11 @@ more stuff
                // Make sure the log entry looks good
                // log_params is not checked here
                $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+               $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
                $this->assertSelect(
-                       [ 'logging' ] + $actorQuery['tables'],
+                       [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'],
                        [
-                               'log_comment',
+                               'log_comment' => $commentQuery['fields']['log_comment_text'],
                                'log_user' => $actorQuery['fields']['log_user'],
                                'log_user_text' => $actorQuery['fields']['log_user_text'],
                                'log_namespace',
@@ -2284,7 +2288,7 @@ more stuff
                                $page->getTitle()->getDBkey(),
                        ] ],
                        [],
-                       $actorQuery['joins']
+                       $actorQuery['joins'] + $commentQuery['joins']
                );
        }