MediaWiki  1.33.0
McrReadNewRevisionStoreDbTest.php
Go to the documentation of this file.
1 <?php
3 
9 use Title;
11 
23 
25 
27  $numberOfSlots = count( $rev->getSlotRoles() );
28 
29  // new schema is written
30  $this->assertSelect(
31  'slots',
32  [ 'count(*)' ],
33  [ 'slot_revision_id' => $rev->getId() ],
34  [ [ (string)$numberOfSlots ] ]
35  );
36 
37  $store = MediaWikiServices::getInstance()->getRevisionStore();
38  $revQuery = $store->getSlotsQueryInfo( [ 'content' ] );
39 
40  $this->assertSelect(
41  $revQuery['tables'],
42  [ 'count(*)' ],
43  [
44  'slot_revision_id' => $rev->getId(),
45  ],
46  [ [ (string)$numberOfSlots ] ],
47  [],
48  $revQuery['joins']
49  );
50 
51  // Legacy schema is still being written
52  $this->assertSelect(
53  [ 'revision', 'text' ],
54  [ 'count(*)' ],
55  [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
56  [ [ 1 ] ],
57  [],
58  [ 'text' => [ 'JOIN', [ 'rev_text_id = old_id' ] ] ]
59  );
60 
61  parent::assertRevisionExistsInDatabase( $rev );
62  }
63 
68  protected function assertSameSlotContent( SlotRecord $a, SlotRecord $b ) {
69  parent::assertSameSlotContent( $a, $b );
70 
71  // Assert that the same content ID has been used
72  $this->assertSame( $a->getContentId(), $b->getContentId() );
73  }
74 
76  foreach ( parent::provideInsertRevisionOn_successes() as $case ) {
77  yield $case;
78  }
79 
80  yield 'Multi-slot revision insertion' => [
81  [
82  'content' => [
83  'main' => new WikitextContent( 'Chicken' ),
84  'aux' => new TextContent( 'Egg' ),
85  ],
86  'page' => true,
87  'comment' => $this->getRandomCommentStoreComment(),
88  'timestamp' => '20171117010101',
89  'user' => true,
90  ],
91  ];
92  }
93 
94  public function provideNewNullRevision() {
95  foreach ( parent::provideNewNullRevision() as $case ) {
96  yield $case;
97  }
98 
99  yield [
100  Title::newFromText( 'UTPage_notAutoCreated' ),
101  [
102  'content' => [
103  'main' => new WikitextContent( 'Chicken' ),
104  'aux' => new WikitextContent( 'Omelet' ),
105  ],
106  ],
107  CommentStoreComment::newUnsavedComment( __METHOD__ . ' comment multi' ),
108  ];
109  }
110 
112  $store = MediaWikiServices::getInstance()->getRevisionStore();
113  $queryInfo = $store->getQueryInfo();
114 
115  // with the new schema enabled, query info should not join the main slot info
116  $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
117  $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
118  }
119 
121  foreach ( parent::provideNewMutableRevisionFromArray() as $case ) {
122  yield $case;
123  }
124 
125  yield 'Basic array, multiple roles' => [
126  [
127  'id' => 2,
128  'page' => 1,
129  'timestamp' => '20171017114835',
130  'user_text' => '111.0.1.2',
131  'user' => 0,
132  'minor_edit' => false,
133  'deleted' => 0,
134  'len' => 29,
135  'parent_id' => 1,
136  'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
137  'comment' => 'Goat Comment!',
138  'content' => [
139  'main' => new WikitextContent( 'Söme Cöntent' ),
140  'aux' => new TextContent( 'Öther Cöntent' ),
141  ]
142  ]
143  ];
144  }
145 
146 }
CommentStoreComment\newUnsavedComment
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
Definition: CommentStoreComment.php:66
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:306
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:45
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest\testGetQueryInfo_NoSlotDataJoin
testGetQueryInfo_NoSlotDataJoin()
Definition: McrReadNewRevisionStoreDbTest.php:111
captcha-old.count
count
Definition: captcha-old.py:249
MediaWiki\Tests\Revision
Definition: FallbackSlotRoleHandlerTest.php:3
$revQuery
$revQuery
Definition: testCompression.php:51
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest\provideNewNullRevision
provideNewNullRevision()
Definition: McrReadNewRevisionStoreDbTest.php:94
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest\provideInsertRevisionOn_successes
provideInsertRevisionOn_successes()
Definition: McrReadNewRevisionStoreDbTest.php:75
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest\provideNewMutableRevisionFromArray
provideNewMutableRevisionFromArray()
Definition: McrReadNewRevisionStoreDbTest.php:120
MediaWiki\Tests\Revision\RevisionStoreDbTestBase
Database RevisionStore.
Definition: RevisionStoreDbTestBase.php:43
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest\assertRevisionExistsInDatabase
assertRevisionExistsInDatabase(RevisionRecord $rev)
Definition: McrReadNewRevisionStoreDbTest.php:26
MediaWikiTestCase\assertSelect
assertSelect( $table, $fields, $condition, array $expectedRows, array $options=[], array $join_conds=[])
Asserts that the given database query yields the rows given by $expectedRows.
Definition: MediaWikiTestCase.php:2000
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest\assertSameSlotContent
assertSameSlotContent(SlotRecord $a, SlotRecord $b)
Definition: McrReadNewRevisionStoreDbTest.php:68
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
MediaWiki\Tests\Revision\McrReadNewRevisionStoreDbTest
Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
Definition: McrReadNewRevisionStoreDbTest.php:22
WikitextContent
Content object for wiki text pages.
Definition: WikitextContent.php:36
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:175
Revision\RevisionRecord\getId
getId()
Get revision ID.
Definition: RevisionRecord.php:273
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:124
MediaWiki\Tests\Revision\RevisionStoreDbTestBase\getRandomCommentStoreComment
getRandomCommentStoreComment()
Definition: RevisionStoreDbTestBase.php:390
TextContent
Content object implementation for representing flat text.
Definition: TextContent.php:37
Title
Represents a title within MediaWiki.
Definition: Title.php:40
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1769
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
Revision\SlotRecord\getContentId
getContentId()
Returns the ID of the content meta data row associated with the slot.
Definition: SlotRecord.php:513
CommentStoreComment
CommentStoreComment represents a comment stored by CommentStore.
Definition: CommentStoreComment.php:29
MediaWiki\Tests\Revision\McrReadNewSchemaOverride
trait McrReadNewSchemaOverride
Trait providing schema overrides that allow tests to run against the intermediate MCR database schema...
Definition: McrReadNewSchemaOverride.php:11
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39