From 0301c8e03aad7b81094c3d31c4f5e4e293d9db5f Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 3 Apr 2019 13:11:46 -0400 Subject: [PATCH] Default $wgActorTableSchemaMigrationStage to READ_NEW Probably good to start testing this in CI sometime soon. The unit tests being changed here are: * Hacky importing of a revision in MessageCacheTest, changed to use an interwiki username. * WikiPageDbTestBase will get null rather than 0 for ar_user. * DumpTestCase was using a custom IP $wgUser when creating its test revisions, which was winding up referring to an actor_id that had been deleted from the database. Fixed by having it use a registered user instead. Also this has MediaWikiTestCase reset the $wgUser User object when the actor table is truncated, as various tests were otherwise failing because it was caching a later-deleted actor ID for User:127.0.0.1. Bug: T188327 Change-Id: Ic483d0fda931810ac639b9de1cc5e5a4ef8161cc Depends-On: I1bd0288cc132627d75b4001219522ec5e952eda7 --- RELEASE-NOTES-1.33 | 4 ++++ includes/DefaultSettings.php | 2 +- tests/phpunit/MediaWikiTestCase.php | 6 ++++++ .../includes/cache/MessageCacheTest.php | 2 +- .../includes/page/WikiPageDbTestBase.php | 2 +- tests/phpunit/maintenance/DumpAsserter.php | 3 ++- tests/phpunit/maintenance/DumpTestCase.php | 2 +- .../maintenance/backupTextPassTest.php | 20 +++++++++++++------ 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 9c5081cd77..8c88911f0d 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -57,6 +57,10 @@ For notes on 1.32.x and older releases, see HISTORY. argon2 to be used, by default, it will automatically choose the best available algorithm depending on which version of PHP you have available. To use this, you can set `$wgPasswordDefault = 'argon2';`. +* $wgActorTableSchemaMigrationStage now defaults to reading the new schema. + update.php will back-populate the new database fields due to the changed + setting, which may take some time on large wikis. You can avoid downtime by + following a process like that described in T188327. ==== Removed configuration ==== * $wgTagStatisticsNewTable (T199334) — This temporary setting, added in diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index cedba704e2..4be3186421 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -8972,7 +8972,7 @@ $wgXmlDumpSchemaVersion = XML_DUMP_SCHEMA_VERSION_10; * @since 1.32 changed allowed flags * @var int An appropriate combination of SCHEMA_COMPAT_XXX flags. */ -$wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_OLD; +$wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW; /** * Flag to enable Partial Blocks. This allows an admin to prevent a user from editing specific pages diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index f43f0a9dd3..3ed21e460b 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1777,6 +1777,12 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { if ( array_intersect( $tablesUsed, $userTables ) ) { $tablesUsed = array_unique( array_merge( $tablesUsed, $userTables ) ); TestUserRegistry::clear(); + + // Reset $wgUser, which is probably 127.0.0.1, as its loaded data is probably not valid + // @todo Should we start setting $wgUser to something nondeterministic + // to encourage tests to be updated to not depend on it? + global $wgUser; + $wgUser->clearInstanceCache( $wgUser->mFrom ); } if ( array_intersect( $tablesUsed, $pageTables ) ) { $tablesUsed = array_unique( array_merge( $tablesUsed, $pageTables ) ); diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php index b03a3098d1..2fa662b88b 100644 --- a/tests/phpunit/includes/cache/MessageCacheTest.php +++ b/tests/phpunit/includes/cache/MessageCacheTest.php @@ -239,7 +239,7 @@ class MessageCacheTest extends MediaWikiLangTestCase { $importRevision->setComment( 'Imported edit' ); $importRevision->setTimestamp( '19991122001122' ); $importRevision->setText( 'IMPORTED OLD TEST' ); - $importRevision->setUsername( 'Alan Smithee' ); + $importRevision->setUsername( 'ext>Alan Smithee' ); $importer = MediaWikiServices::getInstance()->getWikiRevisionOldRevisionImporterNoUpdates(); $importer->import( $importRevision ); diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index ac5fef9389..54875565f4 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -483,7 +483,7 @@ abstract class WikiPageDbTestBase extends MediaWikiLangTestCase { 'delete', 'delete', 'testing user 0 deletion', - '0', + null, '127.0.0.1', (string)$page->getTitle()->getNamespace(), $page->getTitle()->getDBkey(), diff --git a/tests/phpunit/maintenance/DumpAsserter.php b/tests/phpunit/maintenance/DumpAsserter.php index 5b4c6efd50..ad33f6e154 100644 --- a/tests/phpunit/maintenance/DumpAsserter.php +++ b/tests/phpunit/maintenance/DumpAsserter.php @@ -238,7 +238,8 @@ class DumpAsserter { $this->assertNodeStart( "contributor" ); $this->skipWhitespace(); - $this->assertTextNode( "ip", false ); + $this->assertTextNode( "username", false ); + $this->assertTextNode( "id", false ); $this->assertNodeEnd( "contributor" ); $this->skipWhitespace(); diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index 26c9b92dbc..7647915ab9 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -68,7 +68,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { ) { $status = $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), $model ), - $summary + $summary, 0, false, $this->getTestUser()->getUser() ); if ( $status->isGood() ) { diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index 0d4bc56cb0..e059834e29 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -561,6 +561,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { $content = $header; $iterations = intval( $iterations ); + $username = $this->getTestUser()->getUser()->getName(); + $userid = $this->getTestUser()->getUser()->getId(); for ( $i = 0; $i < $iterations; $i++ ) { $page1 = ' BackupDumperTestP1 @@ -570,7 +572,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId1_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP1Summary1 wikitext @@ -588,7 +591,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary1 wikitext @@ -601,7 +605,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary2 wikitext @@ -614,7 +619,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_2 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary3 wikitext @@ -627,7 +633,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId2_3 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' BackupDumperTestP2Summary4 extra wikitext @@ -647,7 +654,8 @@ class TextPassDumperDatabaseTest extends DumpTestCase { ' . ( $this->revId4_1 + $i * self::$numOfRevs ) . ' 2012-04-01T16:46:05Z - 127.0.0.1 + ' . $username . ' + ' . $userid . ' Talk BackupDumperTestP1 Summary1 BackupTextPassTestModel -- 2.20.1