2 namespace MediaWiki\Tests\Storage
;
4 use CommentStoreComment
;
5 use MediaWiki\MediaWikiServices
;
6 use MediaWiki\Storage\RevisionRecord
;
7 use MediaWiki\Storage\SlotRecord
;
13 * Tests RevisionStore against the post-migration MCR DB schema.
15 * @covers \MediaWiki\Storage\RevisionStore
17 * @group RevisionStore
22 class McrRevisionStoreDbTest
extends RevisionStoreDbTestBase
{
24 use McrSchemaOverride
;
26 protected function assertRevisionExistsInDatabase( RevisionRecord
$rev ) {
27 $numberOfSlots = count( $rev->getSlotRoles() );
32 [ 'slot_revision_id' => $rev->getId() ],
33 [ [ (string)$numberOfSlots ] ]
36 $store = MediaWikiServices
::getInstance()->getRevisionStore();
37 $revQuery = $store->getSlotsQueryInfo( [ 'content' ] );
43 'slot_revision_id' => $rev->getId(),
45 [ [ (string)$numberOfSlots ] ],
53 [ 'content_address' => $rev->getSlot( 'main' )->getAddress() ],
57 parent
::assertRevisionExistsInDatabase( $rev );
61 * @param SlotRecord $a
62 * @param SlotRecord $b
64 protected function assertSameSlotContent( SlotRecord
$a, SlotRecord
$b ) {
65 parent
::assertSameSlotContent( $a, $b );
67 // Assert that the same content ID has been used
68 $this->assertSame( $a->getContentId(), $b->getContentId() );
71 public function provideInsertRevisionOn_successes() {
72 foreach ( parent
::provideInsertRevisionOn_successes() as $case ) {
76 yield
'Multi-slot revision insertion' => [
79 'main' => new WikitextContent( 'Chicken' ),
80 'aux' => new TextContent( 'Egg' ),
83 'comment' => $this->getRandomCommentStoreComment(),
84 'timestamp' => '20171117010101',
90 public function provideNewNullRevision() {
91 foreach ( parent
::provideNewNullRevision() as $case ) {
96 Title
::newFromText( 'UTPage_notAutoCreated' ),
99 'main' => new WikitextContent( 'Chicken' ),
100 'aux' => new WikitextContent( 'Omelet' ),
103 CommentStoreComment
::newUnsavedComment( __METHOD__
. ' comment multi' ),
107 public function provideNewMutableRevisionFromArray() {
108 foreach ( parent
::provideNewMutableRevisionFromArray() as $case ) {
112 yield
'Basic array, multiple roles' => [
116 'timestamp' => '20171017114835',
117 'user_text' => '111.0.1.2',
119 'minor_edit' => false,
123 'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
124 'comment' => 'Goat Comment!',
126 'main' => new WikitextContent( 'Söme Cöntent' ),
127 'aux' => new TextContent( 'Öther Cöntent' ),
133 public function testGetQueryInfo_NoSlotDataJoin() {
134 $store = MediaWikiServices
::getInstance()->getRevisionStore();
135 $queryInfo = $store->getQueryInfo();
137 // with the new schema enabled, query info should not join the main slot info
138 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
139 $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
142 public function provideGetArchiveQueryInfo() {
148 'fields' => array_merge(
149 $this->getDefaultArchiveFields( false ),
151 'ar_comment_text' => 'ar_comment',
152 'ar_comment_data' => 'NULL',
153 'ar_comment_cid' => 'NULL',
154 'ar_user_text' => 'ar_user_text',
155 'ar_user' => 'ar_user',
156 'ar_actor' => 'NULL',
165 public function provideGetQueryInfo() {
166 // TODO: more option variations
175 'fields' => array_merge(
176 $this->getDefaultQueryFields( false ),
177 $this->getCommentQueryFields(),
178 $this->getActorQueryFields(),
190 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
191 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
197 public function provideGetSlotsQueryInfo() {
205 'fields' => array_merge(
214 'slot_roles' => [ 'INNER JOIN', [ 'slot_role_id = role_id' ] ],
227 'fields' => array_merge(
240 'slot_roles' => [ 'INNER JOIN', [ 'slot_role_id = role_id' ] ],
241 'content' => [ 'INNER JOIN', [ 'slot_content_id = content_id' ] ],
242 'content_models' => [ 'INNER JOIN', [ 'content_model = model_id' ] ],