MediaWiki  master
NoContentModelRevisionStoreDbTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
18 
20 
21  protected function getContentHandlerUseDB() {
22  return false;
23  }
24 
25  protected function revisionToRow( Revision $rev, $options = [ 'page', 'user', 'comment' ] ) {
26  $row = parent::revisionToRow( $rev, $options );
27 
28  $row->rev_text_id = (string)$rev->getTextId();
29 
30  return $row;
31  }
32 
33  public function provideGetArchiveQueryInfo() {
34  yield [
35  [
36  'tables' => [ 'archive' ],
37  'fields' => array_merge(
38  $this->getDefaultArchiveFields(),
39  [
40  'ar_comment_text' => 'ar_comment',
41  'ar_comment_data' => 'NULL',
42  'ar_comment_cid' => 'NULL',
43  'ar_user_text' => 'ar_user_text',
44  'ar_user' => 'ar_user',
45  'ar_actor' => 'NULL',
46  ]
47  ),
48  'joins' => [],
49  ]
50  ];
51  }
52 
53  public function provideGetQueryInfo() {
54  yield [
55  [],
56  [
57  'tables' => [ 'revision' ],
58  'fields' => array_merge(
59  $this->getDefaultQueryFields(),
60  $this->getCommentQueryFields(),
61  $this->getActorQueryFields()
62  ),
63  'joins' => [],
64  ]
65  ];
66  yield [
67  [ 'page' ],
68  [
69  'tables' => [ 'revision', 'page' ],
70  'fields' => array_merge(
71  $this->getDefaultQueryFields(),
72  $this->getCommentQueryFields(),
73  $this->getActorQueryFields(),
74  [
75  'page_namespace',
76  'page_title',
77  'page_id',
78  'page_latest',
79  'page_is_redirect',
80  'page_len',
81  ]
82  ),
83  'joins' => [
84  'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
85  ],
86  ]
87  ];
88  yield [
89  [ 'user' ],
90  [
91  'tables' => [ 'revision', 'user' ],
92  'fields' => array_merge(
93  $this->getDefaultQueryFields(),
94  $this->getCommentQueryFields(),
95  $this->getActorQueryFields(),
96  [
97  'user_name',
98  ]
99  ),
100  'joins' => [
101  'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
102  ],
103  ]
104  ];
105  yield [
106  [ 'text' ],
107  [
108  'tables' => [ 'revision', 'text' ],
109  'fields' => array_merge(
110  $this->getDefaultQueryFields(),
111  $this->getCommentQueryFields(),
112  $this->getActorQueryFields(),
113  [
114  'old_text',
115  'old_flags',
116  ]
117  ),
118  'joins' => [
119  'text' => [ 'JOIN', [ 'rev_text_id=old_id' ] ],
120  ],
121  ]
122  ];
123  }
124 
125  public function provideGetSlotsQueryInfo() {
126  $db = wfGetDB( DB_REPLICA );
127 
128  yield [
129  [],
130  [
131  'tables' => [
132  'slots' => 'revision',
133  ],
134  'fields' => array_merge(
135  [
136  'slot_revision_id' => 'slots.rev_id',
137  'slot_content_id' => 'NULL',
138  'slot_origin' => 'slots.rev_id',
139  'role_name' => $db->addQuotes( SlotRecord::MAIN ),
140  ]
141  ),
142  'joins' => [],
143  ]
144  ];
145  yield [
146  [ 'content' ],
147  [
148  'tables' => [
149  'slots' => 'revision',
150  ],
151  'fields' => array_merge(
152  [
153  'slot_revision_id' => 'slots.rev_id',
154  'slot_content_id' => 'NULL',
155  'slot_origin' => 'slots.rev_id',
156  'role_name' => $db->addQuotes( SlotRecord::MAIN ),
157  'content_size' => 'slots.rev_len',
158  'content_sha1' => 'slots.rev_sha1',
159  'content_address' =>
160  $db->buildConcat( [ $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ),
161  'model_name' => 'NULL',
162  ]
163  ),
164  'joins' => [],
165  ]
166  ];
167  }
168 
170  foreach ( parent::provideNewMutableRevisionFromArray() as $case ) {
171  yield $case;
172  }
173 
174  yield 'Basic array, with page & id' => [
175  [
176  'id' => 2,
177  'page' => 1,
178  'text_id' => 2,
179  'timestamp' => '20171017114835',
180  'user_text' => '111.0.1.2',
181  'user' => 0,
182  'minor_edit' => false,
183  'deleted' => 0,
184  'len' => 46,
185  'parent_id' => 1,
186  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
187  'comment' => 'Goat Comment!',
188  ]
189  ];
190  }
191 
198  protected function getSlotRevisionConditions( $revId ) {
199  return [ 'rev_id' => $revId ];
200  }
201 
202 }
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
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
trait PreMcrSchemaOverride
Trait providing schema overrides that allow tests to run against the pre-MCR database schema...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1971
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
revisionToRow(Revision $rev, $options=[ 'page', 'user', 'comment'])
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
getTextId()
Get the ID of the row of the text table that contains the content of the revision&#39;s main slot...
Definition: Revision.php:704
const DB_REPLICA
Definition: defines.php:25
getSlotRevisionConditions( $revId)
Conditions to use together with getSlotsQueryInfo() when selecting slot rows for a given revision...
Tests RevisionStore against the pre-MCR, pre-ContentHandler DB schema.