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
$this->setExpectedException( MWException::class );
}
+ $nameTables = MediaWikiServices::getInstance()->getNameTableStoreFactory();
+
$store = new RevisionStore(
$this->getMockLoadBalancer(),
$this->getMockSqlBlobStore(),
$this->getHashWANObjectCache(),
$this->getMockCommentStore(),
- MediaWikiServices::getInstance()->getContentModelStore(),
- MediaWikiServices::getInstance()->getSlotRoleStore(),
+ $nameTables->getContentModels(),
+ $nameTables->getSlotRoles(),
$migrationMode,
MediaWikiServices::getInstance()->getActorMigration()
);
* @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;
}
$blobStore = $this->getMockSqlBlobStore();
$cache = $this->getHashWANObjectCache();
$commentStore = $this->getMockCommentStore();
- $contentModelStore = MediaWikiServices::getInstance()->getContentModelStore();
- $slotRoleStore = MediaWikiServices::getInstance()->getSlotRoleStore();
+ $services = MediaWikiServices::getInstance();
+ $nameTables = $services->getNameTableStoreFactory();
+ $contentModelStore = $nameTables->getContentModels();
+ $slotRoleStore = $nameTables->getSlotRoles();
$store = new RevisionStore(
$loadBalancer,
$blobStore,
$cache,
$commentStore,
- MediaWikiServices::getInstance()->getContentModelStore(),
- MediaWikiServices::getInstance()->getSlotRoleStore(),
+ $nameTables->getContentModels(),
+ $nameTables->getSlotRoles(),
$migration,
- MediaWikiServices::getInstance()->getActorMigration()
+ $services->getActorMigration()
);
if ( !$expectException ) {
$store = TestingAccessWrapper::newFromObject( $store );