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