[MCR] Set MCR migration stage to write-both/read-new.

This patch exists to see if CI passes with
$wgMultiContentRevisionSchemaMigrationStage set to
SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW.

NOTE: verify that $wgMultiContentRevisionSchemaMigrationStage
is explicitly set toSCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
in production config (T197816) before merging this.

Bug: T198561
Depends-On: Ib718868d2c768b6ea851355eef047bc0e6593495
Change-Id: I15989adae2b5916577d164c50d7da88774e49324
This commit is contained in:
daniel 2018-07-04 15:39:24 +02:00
parent 452c71663b
commit 9bd162dce2
5 changed files with 70 additions and 20 deletions

View file

@ -8998,7 +8998,7 @@ $wgCommentTableSchemaMigrationStage = MIGRATION_OLD;
* @since 1.32
* @var int An appropriate combination of SCHEMA_COMPAT_XXX flags.
*/
$wgMultiContentRevisionSchemaMigrationStage = SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD;
$wgMultiContentRevisionSchemaMigrationStage = SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW;
/**
* Actor table schema migration stage.

View file

@ -350,6 +350,7 @@ class Revision implements IDBAccessObject {
*/
public static function selectFields() {
global $wgContentHandlerUseDB, $wgActorTableSchemaMigrationStage;
global $wgMultiContentRevisionSchemaMigrationStage;
if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
// If code is using this instead of self::getQueryInfo(), there's a
@ -361,6 +362,18 @@ class Revision implements IDBAccessObject {
);
}
if ( !( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) ) {
// If code is using this instead of self::getQueryInfo(), there's a
// decent chance it's going to try to directly access
// $row->rev_text_id or $row->rev_content_model and we can't give it
// useful values here once those aren't being written anymore,
// and may not exist at all.
throw new BadMethodCallException(
'Cannot use ' . __METHOD__ . ' when $wgMultiContentRevisionSchemaMigrationStage '
. 'does not have SCHEMA_COMPAT_WRITE_OLD set.'
);
}
wfDeprecated( __METHOD__, '1.31' );
$fields = [
@ -396,6 +409,7 @@ class Revision implements IDBAccessObject {
*/
public static function selectArchiveFields() {
global $wgContentHandlerUseDB, $wgActorTableSchemaMigrationStage;
global $wgMultiContentRevisionSchemaMigrationStage;
if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
// If code is using this instead of self::getQueryInfo(), there's a
@ -407,6 +421,18 @@ class Revision implements IDBAccessObject {
);
}
if ( !( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) ) {
// If code is using this instead of self::getQueryInfo(), there's a
// decent chance it's going to try to directly access
// $row->ar_text_id or $row->ar_content_model and we can't give it
// useful values here once those aren't being written anymore,
// and may not exist at all.
throw new BadMethodCallException(
'Cannot use ' . __METHOD__ . ' when $wgMultiContentRevisionSchemaMigrationStage '
. 'does not have SCHEMA_COMPAT_WRITE_OLD set.'
);
}
wfDeprecated( __METHOD__, '1.31' );
$fields = [

View file

@ -17,9 +17,16 @@ use WANObjectCache;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\LoadBalancer;
use Wikimedia\TestingAccessWrapper;
use WikitextContent;
class RevisionStoreTest extends MediaWikiTestCase {
private function useTextId() {
global $wgMultiContentRevisionSchemaMigrationStage;
return (bool)( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD );
}
/**
* @param LoadBalancer $loadBalancer
* @param SqlBlobStore $blobStore
@ -411,6 +418,10 @@ class RevisionStoreTest extends MediaWikiTestCase {
* @covers \MediaWiki\Storage\RevisionStore::newRevisionFromRow
*/
public function testNewRevisionFromRow_legacyEncoding_applied( $encoding, $locale, $row, $text ) {
if ( !$this->useTextId() ) {
$this->markTestSkipped( 'No longer applicable with MCR schema' );
}
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
@ -432,6 +443,10 @@ class RevisionStoreTest extends MediaWikiTestCase {
* @covers \MediaWiki\Storage\RevisionStore::newRevisionFromRow
*/
public function testNewRevisionFromRow_legacyEncoding_ignored() {
if ( !$this->useTextId() ) {
$this->markTestSkipped( 'No longer applicable with MCR schema' );
}
$row = [
'old_flags' => 'utf-8',
'old_text' => 'Söme Content',
@ -457,7 +472,6 @@ class RevisionStoreTest extends MediaWikiTestCase {
$row = $array + [
'rev_id' => 7,
'rev_page' => 5,
'rev_text_id' => 11,
'rev_timestamp' => '20110101000000',
'rev_user_text' => 'Tester',
'rev_user' => 17,
@ -469,8 +483,6 @@ class RevisionStoreTest extends MediaWikiTestCase {
'rev_comment_text' => 'Testing',
'rev_comment_data' => '{}',
'rev_comment_cid' => 111,
'rev_content_format' => CONTENT_FORMAT_TEXT,
'rev_content_model' => CONTENT_MODEL_TEXT,
'page_namespace' => 0,
'page_title' => 'TEST',
'page_id' => 5,
@ -478,10 +490,24 @@ class RevisionStoreTest extends MediaWikiTestCase {
'page_is_redirect' => 0,
'page_len' => 100,
'user_name' => 'Tester',
'old_is' => 13,
];
if ( $this->useTextId() ) {
$row += [
'rev_content_format' => CONTENT_FORMAT_TEXT,
'rev_content_model' => CONTENT_MODEL_TEXT,
'rev_text_id' => 11,
'old_id' => 11,
'old_text' => 'Hello World',
'old_flags' => 'utf-8',
];
} else {
if ( !isset( $row['content'] ) && isset( $array['old_text'] ) ) {
$row['content'] = [
'main' => new WikitextContent( $array['old_text'] ),
];
}
}
return (object)$row;
}

View file

@ -13,6 +13,10 @@ class TextContentTest extends MediaWikiLangTestCase {
protected function setUp() {
parent::setUp();
// trigger purging of all page related tables
$this->tablesUsed[] = 'page';
$this->tablesUsed[] = 'revision';
// Anon user
$user = new User();
$user->setName( '127.0.0.1' );
@ -352,11 +356,11 @@ class TextContentTest extends MediaWikiLangTestCase {
public static function dataGetDeletionUpdates() {
return [
[ "TextContentTest_testGetSecondaryDataUpdates_1",
[
CONTENT_MODEL_TEXT, "hello ''world''\n",
[]
],
[ "TextContentTest_testGetSecondaryDataUpdates_2",
[
CONTENT_MODEL_TEXT, "hello [[world test 21344]]\n",
[]
],
@ -368,13 +372,11 @@ class TextContentTest extends MediaWikiLangTestCase {
* @dataProvider dataGetDeletionUpdates
* @covers TextContent::getDeletionUpdates
*/
public function testDeletionUpdates( $title, $model, $text, $expectedStuff ) {
$ns = $this->getDefaultWikitextNS();
$title = Title::newFromText( $title, $ns );
public function testDeletionUpdates( $model, $text, $expectedStuff ) {
$page = $this->getNonexistingTestPage( get_class( $this ) . '-' . $this->getName() );
$title = $page->getTitle();
$content = ContentHandler::makeContent( $text, $title, $model );
$page = WikiPage::factory( $title );
$page->doEditContent( $content, '' );
$updates = $content->getDeletionUpdates( $page );
@ -385,11 +387,6 @@ class TextContentTest extends MediaWikiLangTestCase {
$updates[$class] = $update;
}
if ( !$expectedStuff ) {
$this->assertTrue( true ); // make phpunit happy
return;
}
foreach ( $expectedStuff as $class => $fieldValues ) {
$this->assertArrayHasKey( $class, $updates, "missing an update of type $class" );
@ -401,7 +398,8 @@ class TextContentTest extends MediaWikiLangTestCase {
}
}
$page->doDeleteArticle( '' );
// make phpunit happy even if $expectedStuff was empty
$this->assertTrue( true );
}
public static function provideConvert() {

View file

@ -431,11 +431,11 @@ just a test"
public static function dataGetDeletionUpdates() {
return [
[ "WikitextContentTest_testGetSecondaryDataUpdates_1",
[
CONTENT_MODEL_WIKITEXT, "hello ''world''\n",
[ LinksDeletionUpdate::class => [] ]
],
[ "WikitextContentTest_testGetSecondaryDataUpdates_2",
[
CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n",
[ LinksDeletionUpdate::class => [] ]
],