MediaWiki  master
McrReadNewRevisionStoreDbTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10 use Title;
12 
24 
26 
28  $numberOfSlots = count( $rev->getSlotRoles() );
29 
30  // new schema is written
31  $this->assertSelect(
32  'slots',
33  [ 'count(*)' ],
34  [ 'slot_revision_id' => $rev->getId() ],
35  [ [ (string)$numberOfSlots ] ]
36  );
37 
38  $store = MediaWikiServices::getInstance()->getRevisionStore();
39  $revQuery = $store->getSlotsQueryInfo( [ 'content' ] );
40 
41  $this->assertSelect(
42  $revQuery['tables'],
43  [ 'count(*)' ],
44  [
45  'slot_revision_id' => $rev->getId(),
46  ],
47  [ [ (string)$numberOfSlots ] ],
48  [],
49  $revQuery['joins']
50  );
51 
52  // Legacy schema is still being written
53  $this->assertSelect(
54  [ 'revision', 'text' ],
55  [ 'count(*)' ],
56  [ 'rev_id' => $rev->getId(), 'rev_text_id > 0' ],
57  [ [ 1 ] ],
58  [],
59  [ 'text' => [ 'JOIN', [ 'rev_text_id = old_id' ] ] ]
60  );
61 
62  parent::assertRevisionExistsInDatabase( $rev );
63  }
64 
69  protected function assertSameSlotContent( SlotRecord $a, SlotRecord $b ) {
70  parent::assertSameSlotContent( $a, $b );
71 
72  // Assert that the same content ID has been used
73  $this->assertSame( $a->getContentId(), $b->getContentId() );
74  }
75 
77  foreach ( parent::provideInsertRevisionOn_successes() as $case ) {
78  yield $case;
79  }
80 
81  yield 'Multi-slot revision insertion' => [
82  [
83  'content' => [
84  'main' => new WikitextContent( 'Chicken' ),
85  'aux' => new TextContent( 'Egg' ),
86  ],
87  'page' => true,
88  'comment' => $this->getRandomCommentStoreComment(),
89  'timestamp' => '20171117010101',
90  'user' => true,
91  ],
92  ];
93  }
94 
95  public function provideNewNullRevision() {
96  foreach ( parent::provideNewNullRevision() as $case ) {
97  yield $case;
98  }
99 
100  yield [
101  Title::newFromText( 'UTPage_notAutoCreated' ),
102  [
103  'content' => [
104  'main' => new WikitextContent( 'Chicken' ),
105  'aux' => new WikitextContent( 'Omelet' ),
106  ],
107  ],
108  CommentStoreComment::newUnsavedComment( __METHOD__ . ' comment multi' ),
109  ];
110  }
111 
113  $store = MediaWikiServices::getInstance()->getRevisionStore();
114  $queryInfo = $store->getQueryInfo();
115 
116  // with the new schema enabled, query info should not join the main slot info
117  $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['tables'] ) );
118  $this->assertFalse( array_key_exists( 'a_slot_data', $queryInfo['joins'] ) );
119  }
120 
122  foreach ( parent::provideNewMutableRevisionFromArray() as $case ) {
123  yield $case;
124  }
125 
126  yield 'Basic array, multiple roles' => [
127  [
128  'id' => 2,
129  'page' => 1,
130  'timestamp' => '20171017114835',
131  'user_text' => '111.0.1.2',
132  'user' => 0,
133  'minor_edit' => false,
134  'deleted' => 0,
135  'len' => 29,
136  'parent_id' => 1,
137  'sha1' => '89qs83keq9c9ccw9olvvm4oc9oq50ii',
138  'comment' => 'Goat Comment!',
139  'content' => [
140  'main' => new WikitextContent( 'Söme Cöntent' ),
141  'aux' => new TextContent( 'Öther Cöntent' ),
142  ]
143  ]
144  ];
145  }
146 
153  protected function getSlotRevisionConditions( $revId ) {
154  return [ 'slot_revision_id' => $revId ];
155  }
156 
157 }
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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
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
Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39
static getInstance()
Returns the global default instance of the top level service locator.
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
getSlotRoles()
Returns the slot names (roles) of all slots present in this revision.
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:1747
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
getId()
Get revision ID.
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
getSlotRevisionConditions( $revId)
Conditions to use together with getSlotsQueryInfo() when selecting slot rows for a given revision...
getContentId()
Returns the ID of the content meta data row associated with the slot.
Definition: SlotRecord.php:513
$revQuery
Page revision base class.
trait McrReadNewSchemaOverride
Trait providing schema overrides that allow tests to run against the intermediate MCR database schema...
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:320