From 320ec708e4b887a41f1532797cf1a114d240df4b Mon Sep 17 00:00:00 2001 From: Clara Andrew-Wani Date: Tue, 24 Sep 2019 18:07:36 -0400 Subject: [PATCH] Force usage of MCR aware database schema Bug: T214308 Change-Id: I2ae4e82a12f730617563eb6f911fc406b9195391 --- includes/Revision/RevisionStore.php | 10 +- tests/common/TestsAutoLoader.php | 1 - .../NoContentModelRevisionStoreDbTest.php | 202 ------------ .../Revision/PreMcrRevisionStoreDbTest.php | 102 ------ .../Revision/PreMcrSchemaOverride.php | 54 ---- .../Revision/RevisionQueryInfoTest.php | 303 ------------------ .../Revision/RevisionStoreFactoryTest.php | 6 +- .../includes/Revision/RevisionStoreTest.php | 5 +- .../includes/RevisionNoContentModelDbTest.php | 53 --- .../phpunit/includes/RevisionPreMcrDbTest.php | 52 --- .../includes/page/PageArchivePreMcrTest.php | 80 ----- .../page/WikiPageNoContentModelDbTest.php | 44 --- .../includes/page/WikiPagePreMcrDbTest.php | 52 --- 13 files changed, 5 insertions(+), 959 deletions(-) delete mode 100644 tests/phpunit/includes/Revision/NoContentModelRevisionStoreDbTest.php delete mode 100644 tests/phpunit/includes/Revision/PreMcrRevisionStoreDbTest.php delete mode 100644 tests/phpunit/includes/Revision/PreMcrSchemaOverride.php delete mode 100644 tests/phpunit/includes/RevisionNoContentModelDbTest.php delete mode 100644 tests/phpunit/includes/RevisionPreMcrDbTest.php delete mode 100644 tests/phpunit/includes/page/PageArchivePreMcrTest.php delete mode 100644 tests/phpunit/includes/page/WikiPageNoContentModelDbTest.php delete mode 100644 tests/phpunit/includes/page/WikiPagePreMcrDbTest.php diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php index a1aeccb297..c444cc4e7d 100644 --- a/includes/Revision/RevisionStore.php +++ b/includes/Revision/RevisionStore.php @@ -182,9 +182,9 @@ class RevisionStore 'Reading needs to be enabled for the old or the new schema.' ); Assert::parameter( - ( $mcrMigrationStage & SCHEMA_COMPAT_WRITE_BOTH ) !== 0, + ( $mcrMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) !== 0, '$mcrMigrationStage', - 'Writing needs to be enabled for the old or the new schema.' + 'Writing needs to be enabled for the new schema.' ); Assert::parameter( ( $mcrMigrationStage & SCHEMA_COMPAT_READ_OLD ) === 0 @@ -192,12 +192,6 @@ class RevisionStore '$mcrMigrationStage', 'Cannot read the old schema when not also writing it.' ); - Assert::parameter( - ( $mcrMigrationStage & SCHEMA_COMPAT_READ_NEW ) === 0 - || ( $mcrMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) !== 0, - '$mcrMigrationStage', - 'Cannot read the new schema when not also writing it.' - ); $this->loadBalancer = $loadBalancer; $this->blobStore = $blobStore; diff --git a/tests/common/TestsAutoLoader.php b/tests/common/TestsAutoLoader.php index 00ff2c91fd..c479c2d3e3 100644 --- a/tests/common/TestsAutoLoader.php +++ b/tests/common/TestsAutoLoader.php @@ -178,7 +178,6 @@ $wgAutoloadClasses += [ 'MediaWiki\Tests\Revision\RevisionSlotsTest' => "$testDir/phpunit/includes/Revision/RevisionSlotsTest.php", 'MediaWiki\Tests\Revision\RevisionRecordTests' => "$testDir/phpunit/includes/Revision/RevisionRecordTests.php", 'MediaWiki\Tests\Revision\RevisionStoreDbTestBase' => "$testDir/phpunit/includes/Revision/RevisionStoreDbTestBase.php", - 'MediaWiki\Tests\Revision\PreMcrSchemaOverride' => "$testDir/phpunit/includes/Revision/PreMcrSchemaOverride.php", 'MediaWiki\Tests\Revision\RevisionStoreRecordTest' => "$testDir/phpunit/includes/Revision/RevisionStoreRecordTest.php", # tests/phpunit/languages diff --git a/tests/phpunit/includes/Revision/NoContentModelRevisionStoreDbTest.php b/tests/phpunit/includes/Revision/NoContentModelRevisionStoreDbTest.php deleted file mode 100644 index 51cfc63763..0000000000 --- a/tests/phpunit/includes/Revision/NoContentModelRevisionStoreDbTest.php +++ /dev/null @@ -1,202 +0,0 @@ -rev_text_id = (string)$rev->getTextId(); - - return $row; - } - - public function provideGetArchiveQueryInfo() { - yield [ - [ - 'tables' => [ 'archive' ], - 'fields' => array_merge( - $this->getDefaultArchiveFields(), - [ - 'ar_comment_text' => 'ar_comment', - 'ar_comment_data' => 'NULL', - 'ar_comment_cid' => 'NULL', - 'ar_user_text' => 'ar_user_text', - 'ar_user' => 'ar_user', - 'ar_actor' => 'NULL', - ] - ), - 'joins' => [], - ] - ]; - } - - public function provideGetQueryInfo() { - yield [ - [], - [ - 'tables' => [ 'revision' ], - 'fields' => array_merge( - $this->getDefaultQueryFields(), - $this->getCommentQueryFields(), - $this->getActorQueryFields() - ), - 'joins' => [], - ] - ]; - yield [ - [ 'page' ], - [ - 'tables' => [ 'revision', 'page' ], - 'fields' => array_merge( - $this->getDefaultQueryFields(), - $this->getCommentQueryFields(), - $this->getActorQueryFields(), - [ - 'page_namespace', - 'page_title', - 'page_id', - 'page_latest', - 'page_is_redirect', - 'page_len', - ] - ), - 'joins' => [ - 'page' => [ 'JOIN', [ 'page_id = rev_page' ] ], - ], - ] - ]; - yield [ - [ 'user' ], - [ - 'tables' => [ 'revision', 'user' ], - 'fields' => array_merge( - $this->getDefaultQueryFields(), - $this->getCommentQueryFields(), - $this->getActorQueryFields(), - [ - 'user_name', - ] - ), - 'joins' => [ - 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ], - ], - ] - ]; - yield [ - [ 'text' ], - [ - 'tables' => [ 'revision', 'text' ], - 'fields' => array_merge( - $this->getDefaultQueryFields(), - $this->getCommentQueryFields(), - $this->getActorQueryFields(), - [ - 'old_text', - 'old_flags', - ] - ), - 'joins' => [ - 'text' => [ 'JOIN', [ 'rev_text_id=old_id' ] ], - ], - ] - ]; - } - - public function provideGetSlotsQueryInfo() { - $db = wfGetDB( DB_REPLICA ); - - yield [ - [], - [ - 'tables' => [ - 'slots' => 'revision', - ], - 'fields' => array_merge( - [ - 'slot_revision_id' => 'slots.rev_id', - 'slot_content_id' => 'NULL', - 'slot_origin' => 'slots.rev_id', - 'role_name' => $db->addQuotes( SlotRecord::MAIN ), - ] - ), - 'joins' => [], - ] - ]; - yield [ - [ 'content' ], - [ - 'tables' => [ - 'slots' => 'revision', - ], - 'fields' => array_merge( - [ - 'slot_revision_id' => 'slots.rev_id', - 'slot_content_id' => 'NULL', - 'slot_origin' => 'slots.rev_id', - 'role_name' => $db->addQuotes( SlotRecord::MAIN ), - 'content_size' => 'slots.rev_len', - 'content_sha1' => 'slots.rev_sha1', - 'content_address' => - $db->buildConcat( [ $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ), - 'model_name' => 'NULL', - ] - ), - 'joins' => [], - ] - ]; - } - - public function provideNewMutableRevisionFromArray() { - foreach ( parent::provideNewMutableRevisionFromArray() as $case ) { - yield $case; - } - - yield 'Basic array, with page & id' => [ - [ - 'id' => 2, - 'page' => 1, - 'text_id' => 2, - 'timestamp' => '20171017114835', - 'user_text' => '111.0.1.2', - 'user' => 0, - 'minor_edit' => false, - 'deleted' => 0, - 'len' => 46, - 'parent_id' => 1, - 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z', - 'comment' => 'Goat Comment!', - ] - ]; - } - - /** - * Conditions to use together with getSlotsQueryInfo() when selecting slot rows for a given - * revision. - * - * @return array - */ - protected function getSlotRevisionConditions( $revId ) { - return [ 'rev_id' => $revId ]; - } - -} diff --git a/tests/phpunit/includes/Revision/PreMcrRevisionStoreDbTest.php b/tests/phpunit/includes/Revision/PreMcrRevisionStoreDbTest.php deleted file mode 100644 index 468ab60800..0000000000 --- a/tests/phpunit/includes/Revision/PreMcrRevisionStoreDbTest.php +++ /dev/null @@ -1,102 +0,0 @@ -rev_text_id = (string)$rev->getTextId(); - $row->rev_content_format = (string)$rev->getContentFormat(); - $row->rev_content_model = (string)$rev->getContentModel(); - - return $row; - } - - protected function assertRevisionExistsInDatabase( RevisionRecord $rev ) { - // Legacy schema is still being written - $this->assertSelect( - [ 'revision', 'text' ], - [ 'count(*)' ], - [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ], - [ [ 1 ] ], - [], - [ 'text' => [ 'JOIN', [ 'rev_text_id = old_id' ] ] ] - ); - - parent::assertRevisionExistsInDatabase( $rev ); - } - - public function provideInsertRevisionOn_failures() { - foreach ( parent::provideInsertRevisionOn_failures() as $case ) { - yield $case; - } - - yield 'slot that is not main slot' => [ - [ - 'content' => [ - 'main' => new WikitextContent( 'Chicken' ), - 'lalala' => new WikitextContent( 'Duck' ), - ], - 'comment' => $this->getRandomCommentStoreComment(), - 'timestamp' => '20171117010101', - 'user' => true, - ], - new InvalidArgumentException( 'Only the main slot is supported' ) - ]; - } - - public function provideNewMutableRevisionFromArray() { - foreach ( parent::provideNewMutableRevisionFromArray() as $case ) { - yield $case; - } - - yield 'Basic array, with page & id' => [ - [ - 'id' => 2, - 'page' => 1, - 'text_id' => 2, - 'timestamp' => '20171017114835', - 'user_text' => '111.0.1.2', - 'user' => 0, - 'minor_edit' => false, - 'deleted' => 0, - 'len' => 46, - 'parent_id' => 1, - 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z', - 'comment' => 'Goat Comment!', - 'content_format' => 'text/x-wiki', - 'content_model' => 'wikitext', - ] - ]; - } - - /** - * Conditions to use together with getSlotsQueryInfo() when selecting slot rows for a given - * revision. - * - * @return array - */ - protected function getSlotRevisionConditions( $revId ) { - return [ 'rev_id' => $revId ]; - } - -} diff --git a/tests/phpunit/includes/Revision/PreMcrSchemaOverride.php b/tests/phpunit/includes/Revision/PreMcrSchemaOverride.php deleted file mode 100644 index 1fe2d6f8e5..0000000000 --- a/tests/phpunit/includes/Revision/PreMcrSchemaOverride.php +++ /dev/null @@ -1,54 +0,0 @@ - [], - 'drop' => [], - 'create' => [], - 'alter' => [], - ]; - - if ( $this->hasMcrTables( $db ) ) { - $overrides['drop'] = [ 'slots', 'content', 'slot_roles', 'content_models', ]; - $overrides['scripts'][] = $this->getSqlPatchPath( $db, '/drop-mcr-tables', __DIR__ ); - } - - if ( !$this->hasPreMcrFields( $db ) ) { - $overrides['alter'][] = 'revision'; - $overrides['scripts'][] = $this->getSqlPatchPath( $db, '/create-pre-mcr-fields', __DIR__ ); - } - - return $overrides; - } - -} diff --git a/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php b/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php index 949b664e29..0196c5da8c 100644 --- a/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php +++ b/tests/phpunit/includes/Revision/RevisionQueryInfoTest.php @@ -172,29 +172,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase { ], ] ]; - yield 'pre-MCR, no model' => [ - [ - 'wgContentHandlerUseDB' => false, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [ - 'tables' => [ - 'archive', - 'actor_ar_user' => 'actor', - 'comment_ar_comment' => 'comment', - ], - 'fields' => array_merge( - $this->getArchiveQueryFields( true ), - $this->getNewActorQueryFields( 'ar' ), - $this->getNewCommentQueryFields( 'ar' ) - ), - 'joins' => [ - 'comment_ar_comment' - => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ], - 'actor_ar_user' => [ 'JOIN', 'actor_ar_user.actor_id = ar_actor' ], - ], - ] - ]; } public function provideQueryInfo() { @@ -397,238 +374,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase { ], ] ]; - yield 'pre-MCR' => [ - [ - 'wgContentHandlerUseDB' => true, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [], - [ - 'tables' => [ - 'revision', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getContentHandlerQueryFields( 'rev' ), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ] - ]; - yield 'pre-MCR, page, user' => [ - [ - 'wgContentHandlerUseDB' => true, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [ 'page', 'user' ], - [ - 'tables' => [ - 'revision', 'page', 'user', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getContentHandlerQueryFields( 'rev' ), - $this->getPageQueryFields(), - $this->getUserQueryFields(), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( 'rev' ) - ), - 'joins' => [ - 'page' => [ 'JOIN', [ 'page_id = rev_page' ] ], - 'user' => [ 'LEFT JOIN', [ - 'actor_rev_user.actor_user != 0', - '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ] - ]; - yield 'pre-MCR, no model' => [ - [ - 'wgContentHandlerUseDB' => false, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [], - [ - 'tables' => [ - 'revision', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ], - ]; - yield 'pre-MCR, no model, page' => [ - [ - 'wgContentHandlerUseDB' => false, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [ 'page' ], - [ - 'tables' => [ - 'revision', 'page', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getPageQueryFields(), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( 'rev' ) - ), - 'joins' => [ - 'page' => [ '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ], - ]; - yield 'pre-MCR, no model, user' => [ - [ - 'wgContentHandlerUseDB' => false, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [ 'user' ], - [ - 'tables' => [ - 'revision', 'user', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getUserQueryFields(), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( 'rev' ) - ), - 'joins' => [ - 'user' => [ 'LEFT JOIN', [ - 'actor_rev_user.actor_user != 0', - '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ], - ]; - yield 'pre-MCR, no model, text' => [ - [ - 'wgContentHandlerUseDB' => false, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [ 'text' ], - [ - 'tables' => [ - 'revision', 'text', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getTextQueryFields(), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( 'rev' ) - ), - 'joins' => [ - 'text' => [ '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ], - ]; - yield 'pre-MCR, no model, text, page, user' => [ - [ - 'wgContentHandlerUseDB' => false, - 'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD, - ], - [ 'text', 'page', 'user' ], - [ - 'tables' => [ - 'revision', 'page', 'user', 'text', - 'temp_rev_comment' => 'revision_comment_temp', - 'comment_rev_comment' => 'comment', - 'temp_rev_user' => 'revision_actor_temp', - 'actor_rev_user' => 'actor', - ], - 'fields' => array_merge( - $this->getRevisionQueryFields( true ), - $this->getPageQueryFields(), - $this->getUserQueryFields(), - $this->getTextQueryFields(), - $this->getNewActorQueryFields( 'rev', true ), - $this->getNewCommentQueryFields( 'rev' ) - ), - 'joins' => [ - 'page' => [ - 'JOIN', - [ 'page_id = rev_page' ], - ], - 'user' => [ - 'LEFT JOIN', - [ - 'actor_rev_user.actor_user != 0', - 'user_id = actor_rev_user.actor_user', - ], - ], - 'text' => [ - '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' ], - 'temp_rev_user' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ], - 'actor_rev_user' => [ 'JOIN', 'actor_rev_user.actor_id = temp_rev_user.revactor_actor' ], - ], - ], - ]; } public function provideSlotsQueryInfo() { @@ -805,54 +550,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase { 'joins' => [], ] ]; - yield 'pre-MCR' => [ - [ - 'wgMultiContentRevisionSchemaMigrationStage' - => SCHEMA_COMPAT_OLD, - ], - [], - [ - 'tables' => [ - 'revision', - ], - 'fields' => array_merge( - [ - 'slot_revision_id' => 'rev_id', - 'slot_content_id' => 'NULL', - 'slot_origin' => 'rev_id', - 'role_name' => $db->addQuotes( SlotRecord::MAIN ), - ] - ), - 'joins' => [], - ] - ]; - yield 'pre-MCR, content' => [ - [ - 'wgMultiContentRevisionSchemaMigrationStage' - => SCHEMA_COMPAT_OLD, - ], - [ 'content' ], - [ - 'tables' => [ - 'revision', - ], - 'fields' => array_merge( - [ - 'slot_revision_id' => 'rev_id', - 'slot_content_id' => 'NULL', - 'slot_origin' => 'rev_id', - 'role_name' => $db->addQuotes( SlotRecord::MAIN ), - 'content_size' => 'rev_len', - 'content_sha1' => 'rev_sha1', - 'content_address' => - $db->buildConcat( [ $db->addQuotes( 'tt:' ), 'rev_text_id' ] ), - 'rev_text_id' => 'rev_text_id', - 'model_name' => 'rev_content_model', - ] - ), - 'joins' => [], - ] - ]; } /** diff --git a/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php b/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php index 99332d2488..d42ab16fbc 100644 --- a/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php +++ b/tests/phpunit/includes/Revision/RevisionStoreFactoryTest.php @@ -33,7 +33,7 @@ class RevisionStoreFactoryTest extends \MediaWikiIntegrationTestCase { $this->getHashWANObjectCache(), $this->getMockCommentStore(), ActorMigration::newMigration(), - MIGRATION_OLD, + MIGRATION_NEW, new NullLogger(), true ); @@ -44,8 +44,6 @@ class RevisionStoreFactoryTest extends \MediaWikiIntegrationTestCase { yield [ true ]; yield [ false ]; yield [ 'somewiki' ]; - yield [ 'somewiki', MIGRATION_OLD , false ]; - yield [ 'somewiki', MIGRATION_NEW , true ]; } /** @@ -54,7 +52,7 @@ class RevisionStoreFactoryTest extends \MediaWikiIntegrationTestCase { */ public function testGetRevisionStore( $dbDomain, - $mcrMigrationStage = MIGRATION_OLD, + $mcrMigrationStage = MIGRATION_NEW, $contentHandlerUseDb = true ) { $lbFactory = $this->getMockLoadBalancerFactory(); diff --git a/tests/phpunit/includes/Revision/RevisionStoreTest.php b/tests/phpunit/includes/Revision/RevisionStoreTest.php index 83872e3a37..9b26c3761f 100644 --- a/tests/phpunit/includes/Revision/RevisionStoreTest.php +++ b/tests/phpunit/includes/Revision/RevisionStoreTest.php @@ -120,9 +120,7 @@ class RevisionStoreTest extends MediaWikiTestCase { public function provideSetContentHandlerUseDB() { return [ - // ContentHandlerUseDB can be true of false pre migration. - [ false, SCHEMA_COMPAT_OLD, false ], - [ true, SCHEMA_COMPAT_OLD, false ], + // ContentHandlerUseDB can be true or false pre migration. // During and after migration it can not be false... [ false, SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD, true ], [ false, SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW, true ], @@ -563,7 +561,6 @@ class RevisionStoreTest extends MediaWikiTestCase { public function provideMigrationConstruction() { return [ - [ SCHEMA_COMPAT_OLD, false ], [ SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD, false ], [ SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW, false ], [ SCHEMA_COMPAT_NEW, false ], diff --git a/tests/phpunit/includes/RevisionNoContentModelDbTest.php b/tests/phpunit/includes/RevisionNoContentModelDbTest.php deleted file mode 100644 index f19bc52bb8..0000000000 --- a/tests/phpunit/includes/RevisionNoContentModelDbTest.php +++ /dev/null @@ -1,53 +0,0 @@ - 7, - 'rev_page' => 1, // should match actual page id - 'rev_text_id' => 789, - 'rev_timestamp' => '20180101000000', - 'rev_len' => 7, - 'rev_minor_edit' => 0, - 'rev_deleted' => 0, - 'rev_parent_id' => 0, - 'rev_sha1' => 'deadbeef', - 'rev_comment' => 'some comment', - 'rev_comment_text' => 'some comment', - 'rev_comment_data' => '{}', - 'rev_user' => 17, - 'rev_user_text' => 'some user', - ]; - - yield [ $row, 789 ]; - } - - public function provideGetRevisionText() { - yield [ - [ 'text' ] - ]; - } - -} diff --git a/tests/phpunit/includes/RevisionPreMcrDbTest.php b/tests/phpunit/includes/RevisionPreMcrDbTest.php deleted file mode 100644 index 444c150efb..0000000000 --- a/tests/phpunit/includes/RevisionPreMcrDbTest.php +++ /dev/null @@ -1,52 +0,0 @@ - 7, - 'rev_page' => 1, // should match actual page id - 'rev_text_id' => 789, - 'rev_timestamp' => '20180101000000', - 'rev_len' => 7, - 'rev_minor_edit' => 0, - 'rev_deleted' => 0, - 'rev_parent_id' => 0, - 'rev_sha1' => 'deadbeef', - 'rev_comment' => 'some comment', - 'rev_comment_text' => 'some comment', - 'rev_comment_data' => '{}', - 'rev_user' => 17, - 'rev_user_text' => 'some user', - ]; - - yield [ $row, 789 ]; - } - - public function provideGetRevisionText() { - yield [ - [ 'text' ] - ]; - } -} diff --git a/tests/phpunit/includes/page/PageArchivePreMcrTest.php b/tests/phpunit/includes/page/PageArchivePreMcrTest.php deleted file mode 100644 index 4c955796f8..0000000000 --- a/tests/phpunit/includes/page/PageArchivePreMcrTest.php +++ /dev/null @@ -1,80 +0,0 @@ -getBlobStore(); - - return [ - [ - 'ar_minor_edit' => '0', - 'ar_user' => null, - 'ar_user_text' => $this->ipEditor, - 'ar_actor' => (string)User::newFromName( $this->ipEditor, false )->getActorId( $this->db ), - 'ar_len' => '11', - 'ar_deleted' => '0', - 'ar_rev_id' => strval( $this->ipRev->getId() ), - 'ar_timestamp' => $this->db->timestamp( $this->ipRev->getTimestamp() ), - 'ar_sha1' => '0qdrpxl537ivfnx4gcpnzz0285yxryy', - 'ar_page_id' => strval( $this->ipRev->getPageId() ), - 'ar_comment_text' => 'just a test', - 'ar_comment_data' => null, - 'ar_comment_cid' => '2', - 'ar_content_format' => null, - 'ar_content_model' => null, - 'ts_tags' => null, - 'ar_id' => '2', - 'ar_namespace' => '0', - 'ar_title' => 'PageArchiveTest_thePage', - 'ar_text_id' => (string)$blobStore->getTextIdFromAddress( - $this->ipRev->getSlot( SlotRecord::MAIN )->getAddress() - ), - 'ar_parent_id' => strval( $this->ipRev->getParentId() ), - ], - [ - 'ar_minor_edit' => '0', - 'ar_user' => (string)$this->getTestUser()->getUser()->getId(), - 'ar_user_text' => $this->getTestUser()->getUser()->getName(), - 'ar_actor' => (string)$this->getTestUser()->getUser()->getActorId(), - 'ar_len' => '7', - 'ar_deleted' => '0', - 'ar_rev_id' => strval( $this->firstRev->getId() ), - 'ar_timestamp' => $this->db->timestamp( $this->firstRev->getTimestamp() ), - 'ar_sha1' => 'pr0s8e18148pxhgjfa0gjrvpy8fiyxc', - 'ar_page_id' => strval( $this->firstRev->getPageId() ), - 'ar_comment_text' => 'testing', - 'ar_comment_data' => null, - 'ar_comment_cid' => '1', - 'ar_content_format' => null, - 'ar_content_model' => null, - 'ts_tags' => null, - 'ar_id' => '1', - 'ar_namespace' => '0', - 'ar_title' => 'PageArchiveTest_thePage', - 'ar_text_id' => (string)$blobStore->getTextIdFromAddress( - $this->firstRev->getSlot( SlotRecord::MAIN )->getAddress() - ), - 'ar_parent_id' => '0', - ], - ]; - } - -} diff --git a/tests/phpunit/includes/page/WikiPageNoContentModelDbTest.php b/tests/phpunit/includes/page/WikiPageNoContentModelDbTest.php deleted file mode 100644 index 6f8d36332f..0000000000 --- a/tests/phpunit/includes/page/WikiPageNoContentModelDbTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getDefaultWikitextNS(), __METHOD__ ); - $page = new WikiPage( $title ); - $page = $this->createPage( - $page, - [ 'main' => $mainContent1 ] - ); - - $dataUpdates = $page->getDeletionUpdates( $page->getRevisionRecord() ); - $this->assertNotEmpty( $dataUpdates ); - - $updateNames = array_map( function ( $du ) { - return isset( $du->_name ) ? $du->_name : get_class( $du ); - }, $dataUpdates ); - - $this->assertContains( LinksDeletionUpdate::class, $updateNames ); - } - -} diff --git a/tests/phpunit/includes/page/WikiPagePreMcrDbTest.php b/tests/phpunit/includes/page/WikiPagePreMcrDbTest.php deleted file mode 100644 index 028becadde..0000000000 --- a/tests/phpunit/includes/page/WikiPagePreMcrDbTest.php +++ /dev/null @@ -1,52 +0,0 @@ -createPage( - __METHOD__, - "some text", - CONTENT_MODEL_JAVASCRIPT - ); - - $page = new WikiPage( $page->getTitle() ); - $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $page->getContentModel() ); - } - - /** - * @covers WikiPage::getContentHandler - */ - public function testGetContentHandler() { - $page = $this->createPage( - __METHOD__, - "some text", - CONTENT_MODEL_JAVASCRIPT - ); - - $page = new WikiPage( $page->getTitle() ); - $this->assertEquals( JavaScriptContentHandler::class, get_class( $page->getContentHandler() ) ); - } - -} -- 2.20.1