* @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.
*/
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
);
}
+ 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 = [
*/
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
);
}
+ 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 = [
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
* @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();
* @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',
$row = $array + [
'rev_id' => 7,
'rev_page' => 5,
- 'rev_text_id' => 11,
'rev_timestamp' => '20110101000000',
'rev_user_text' => 'Tester',
'rev_user' => 17,
'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,
'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;
}
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' );
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",
[]
],
* @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 );
$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" );
}
}
- $page->doDeleteArticle( '' );
+ // make phpunit happy even if $expectedStuff was empty
+ $this->assertTrue( true );
}
public static function provideConvert() {
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 => [] ]
],