@@ -20,35 +20,35 @@ |
||
20 | 20 | public const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup'; |
21 | 21 | public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
22 | 22 | |
23 | - private static function getService( ?MediaWikiServices $services, $name ) { |
|
24 | - if ( $services === null ) { |
|
23 | + private static function getService(?MediaWikiServices $services, $name) { |
|
24 | + if ($services === null) { |
|
25 | 25 | $services = MediaWikiServices::getInstance(); |
26 | 26 | } |
27 | - return $services->getService( $name ); |
|
27 | + return $services->getService($name); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param MediaWikiServices|null $services |
32 | 32 | * @return EntityLookup |
33 | 33 | */ |
34 | - public static function getEntityLookup( MediaWikiServices $services = null ) { |
|
35 | - return self::getService( $services, self::ENTITY_LOOKUP ); |
|
34 | + public static function getEntityLookup(MediaWikiServices $services = null) { |
|
35 | + return self::getService($services, self::ENTITY_LOOKUP); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @param MediaWikiServices|null $services |
40 | 40 | * @return PropertyDataTypeLookup |
41 | 41 | */ |
42 | - public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) { |
|
43 | - return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP ); |
|
42 | + public static function getPropertyDataTypeLookup(MediaWikiServices $services = null) { |
|
43 | + return self::getService($services, self::PROPERTY_DATA_TYPE_LOOKUP); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param MediaWikiServices|null $services |
48 | 48 | * @return EntityLookup |
49 | 49 | */ |
50 | - public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ) { |
|
51 | - return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE ); |
|
50 | + public static function getEntityLookupWithoutCache(MediaWikiServices $services = null) { |
|
51 | + return self::getService($services, self::ENTITY_LOOKUP_WITHOUT_CACHE); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | * @param ViolationMessage $violationMessage |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function render( ViolationMessage $violationMessage ) { |
|
80 | + public function render(ViolationMessage $violationMessage) { |
|
81 | 81 | $messageKey = $violationMessage->getMessageKey(); |
82 | - $paramsLists = [ [] ]; |
|
83 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
84 | - $params = $this->renderArgument( $argument ); |
|
82 | + $paramsLists = [[]]; |
|
83 | + foreach ($violationMessage->getArguments() as $argument) { |
|
84 | + $params = $this->renderArgument($argument); |
|
85 | 85 | $paramsLists[] = $params; |
86 | 86 | } |
87 | - $allParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
87 | + $allParams = call_user_func_array('array_merge', $paramsLists); |
|
88 | 88 | return $this->messageLocalizer |
89 | - ->msg( $messageKey ) |
|
90 | - ->params( $allParams ) |
|
89 | + ->msg($messageKey) |
|
90 | + ->params($allParams) |
|
91 | 91 | ->escaped(); |
92 | 92 | } |
93 | 93 | |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | * @param string|null $role one of the Role::* constants |
97 | 97 | * @return string HTML |
98 | 98 | */ |
99 | - protected function addRole( $value, $role ) { |
|
100 | - if ( $role === null ) { |
|
99 | + protected function addRole($value, $role) { |
|
100 | + if ($role === null) { |
|
101 | 101 | return $value; |
102 | 102 | } |
103 | 103 | |
104 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
105 | - $value . |
|
104 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
105 | + $value. |
|
106 | 106 | '</span>'; |
107 | 107 | } |
108 | 108 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @param string $key message key |
111 | 111 | * @return string HTML |
112 | 112 | */ |
113 | - protected function msgEscaped( $key ) { |
|
114 | - return $this->messageLocalizer->msg( $key )->escaped(); |
|
113 | + protected function msgEscaped($key) { |
|
114 | + return $this->messageLocalizer->msg($key)->escaped(); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param array $argument |
119 | 119 | * @return array[] params (for Message::params) |
120 | 120 | */ |
121 | - protected function renderArgument( array $argument ) { |
|
121 | + protected function renderArgument(array $argument) { |
|
122 | 122 | $methods = [ |
123 | 123 | ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId', |
124 | 124 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList', |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | $value = $argument['value']; |
139 | 139 | $role = $argument['role']; |
140 | 140 | |
141 | - if ( array_key_exists( $type, $methods ) ) { |
|
141 | + if (array_key_exists($type, $methods)) { |
|
142 | 142 | $method = $methods[$type]; |
143 | - $params = $this->$method( $value, $role ); |
|
143 | + $params = $this->$method($value, $role); |
|
144 | 144 | } else { |
145 | 145 | throw new InvalidArgumentException( |
146 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
146 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
147 | 147 | ); |
148 | 148 | } |
149 | 149 | |
@@ -157,46 +157,46 @@ discard block |
||
157 | 157 | * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ]) |
158 | 158 | * @return array[] list of parameters as accepted by Message::params() |
159 | 159 | */ |
160 | - private function renderList( array $list, $role, callable $render ) { |
|
161 | - if ( $list === [] ) { |
|
160 | + private function renderList(array $list, $role, callable $render) { |
|
161 | + if ($list === []) { |
|
162 | 162 | return [ |
163 | - Message::numParam( 0 ), |
|
164 | - Message::rawParam( '<ul></ul>' ), |
|
163 | + Message::numParam(0), |
|
164 | + Message::rawParam('<ul></ul>'), |
|
165 | 165 | ]; |
166 | 166 | } |
167 | 167 | |
168 | - if ( count( $list ) > $this->maxListLength ) { |
|
169 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
168 | + if (count($list) > $this->maxListLength) { |
|
169 | + $list = array_slice($list, 0, $this->maxListLength); |
|
170 | 170 | $truncated = true; |
171 | 171 | } |
172 | 172 | |
173 | 173 | $renderedParamsLists = array_map( |
174 | 174 | $render, |
175 | 175 | $list, |
176 | - array_fill( 0, count( $list ), $role ) |
|
176 | + array_fill(0, count($list), $role) |
|
177 | 177 | ); |
178 | 178 | $renderedParams = array_map( |
179 | - function ( $params ) { |
|
179 | + function($params) { |
|
180 | 180 | return $params[0]; |
181 | 181 | }, |
182 | 182 | $renderedParamsLists |
183 | 183 | ); |
184 | 184 | $renderedElements = array_map( |
185 | - function ( $param ) { |
|
185 | + function($param) { |
|
186 | 186 | return $param['raw']; |
187 | 187 | }, |
188 | 188 | $renderedParams |
189 | 189 | ); |
190 | - if ( isset( $truncated ) ) { |
|
191 | - $renderedElements[] = $this->msgEscaped( 'ellipsis' ); |
|
190 | + if (isset($truncated)) { |
|
191 | + $renderedElements[] = $this->msgEscaped('ellipsis'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return array_merge( |
195 | 195 | [ |
196 | - Message::numParam( count( $list ) ), |
|
196 | + Message::numParam(count($list)), |
|
197 | 197 | Message::rawParam( |
198 | - '<ul><li>' . |
|
199 | - implode( '</li><li>', $renderedElements ) . |
|
198 | + '<ul><li>'. |
|
199 | + implode('</li><li>', $renderedElements). |
|
200 | 200 | '</li></ul>' |
201 | 201 | ), |
202 | 202 | ], |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param string|null $role one of the Role::* constants |
210 | 210 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
211 | 211 | */ |
212 | - private function renderEntityId( EntityId $entityId, $role ) { |
|
213 | - return [ Message::rawParam( $this->addRole( |
|
214 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
212 | + private function renderEntityId(EntityId $entityId, $role) { |
|
213 | + return [Message::rawParam($this->addRole( |
|
214 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
215 | 215 | $role |
216 | - ) ) ]; |
|
216 | + ))]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string|null $role one of the Role::* constants |
222 | 222 | * @return array[] list of parameters as accepted by Message::params() |
223 | 223 | */ |
224 | - private function renderEntityIdList( array $entityIdList, $role ) { |
|
225 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
224 | + private function renderEntityIdList(array $entityIdList, $role) { |
|
225 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -230,24 +230,24 @@ discard block |
||
230 | 230 | * @param string|null $role one of the Role::* constants |
231 | 231 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
232 | 232 | */ |
233 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) { |
|
234 | - switch ( true ) { |
|
233 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) { |
|
234 | + switch (true) { |
|
235 | 235 | case $value->isValue(): |
236 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
236 | + return $this->renderEntityId($value->getItemId(), $role); |
|
237 | 237 | case $value->isSomeValue(): |
238 | - return [ Message::rawParam( $this->addRole( |
|
239 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
240 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) . |
|
238 | + return [Message::rawParam($this->addRole( |
|
239 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
240 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue'). |
|
241 | 241 | '</span>', |
242 | 242 | $role |
243 | - ) ) ]; |
|
243 | + ))]; |
|
244 | 244 | case $value->isNoValue(): |
245 | - return [ Message::rawParam( $this->addRole( |
|
246 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
247 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) . |
|
245 | + return [Message::rawParam($this->addRole( |
|
246 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
247 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-novalue'). |
|
248 | 248 | '</span>', |
249 | 249 | $role |
250 | - ) ) ]; |
|
250 | + ))]; |
|
251 | 251 | default: |
252 | 252 | // @codeCoverageIgnoreStart |
253 | 253 | throw new LogicException( |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @param string|null $role one of the Role::* constants |
263 | 263 | * @return array[] list of parameters as accepted by Message::params() |
264 | 264 | */ |
265 | - private function renderItemIdSnakValueList( array $valueList, $role ) { |
|
266 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
265 | + private function renderItemIdSnakValueList(array $valueList, $role) { |
|
266 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | * @param string|null $role one of the Role::* constants |
272 | 272 | * @return array[] list of parameters as accepted by Message::params() |
273 | 273 | */ |
274 | - private function renderDataValue( DataValue $dataValue, $role ) { |
|
275 | - return [ Message::rawParam( $this->addRole( |
|
276 | - $this->dataValueFormatter->format( $dataValue ), |
|
274 | + private function renderDataValue(DataValue $dataValue, $role) { |
|
275 | + return [Message::rawParam($this->addRole( |
|
276 | + $this->dataValueFormatter->format($dataValue), |
|
277 | 277 | $role |
278 | - ) ) ]; |
|
278 | + ))]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param string|null $role one of the Role::* constants |
284 | 284 | * @return array[] list of parameters as accepted by Message::params() |
285 | 285 | */ |
286 | - private function renderDataValueType( $dataValueType, $role ) { |
|
286 | + private function renderDataValueType($dataValueType, $role) { |
|
287 | 287 | $messageKeys = [ |
288 | 288 | 'string' => 'datatypes-type-string', |
289 | 289 | 'monolingualtext' => 'datatypes-type-monolingualtext', |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
293 | 293 | ]; |
294 | 294 | |
295 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
296 | - return [ Message::rawParam( $this->addRole( |
|
297 | - $this->msgEscaped( $messageKeys[$dataValueType] ), |
|
295 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
296 | + return [Message::rawParam($this->addRole( |
|
297 | + $this->msgEscaped($messageKeys[$dataValueType]), |
|
298 | 298 | $role |
299 | - ) ) ]; |
|
299 | + ))]; |
|
300 | 300 | } else { |
301 | 301 | // @codeCoverageIgnoreStart |
302 | 302 | throw new LogicException( |
303 | - 'Unknown data value type ' . $dataValueType |
|
303 | + 'Unknown data value type '.$dataValueType |
|
304 | 304 | ); |
305 | 305 | // @codeCoverageIgnoreEnd |
306 | 306 | } |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | * @param string|null $role one of the Role::* constants |
312 | 312 | * @return array[] list of parameters as accepted by Message::params() |
313 | 313 | */ |
314 | - private function renderInlineCode( $code, $role ) { |
|
315 | - return [ Message::rawParam( $this->addRole( |
|
316 | - '<code>' . htmlspecialchars( $code ) . '</code>', |
|
314 | + private function renderInlineCode($code, $role) { |
|
315 | + return [Message::rawParam($this->addRole( |
|
316 | + '<code>'.htmlspecialchars($code).'</code>', |
|
317 | 317 | $role |
318 | - ) ) ]; |
|
318 | + ))]; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string|null $role one of the Role::* constants |
324 | 324 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
325 | 325 | */ |
326 | - private function renderConstraintScope( $scope, $role ) { |
|
327 | - switch ( $scope ) { |
|
326 | + private function renderConstraintScope($scope, $role) { |
|
327 | + switch ($scope) { |
|
328 | 328 | case Context::TYPE_STATEMENT: |
329 | 329 | $itemId = $this->config->get( |
330 | 330 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | // callers should never let this happen, but if it does happen, |
345 | 345 | // showing “unknown value” seems reasonable |
346 | 346 | // @codeCoverageIgnoreStart |
347 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
347 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
348 | 348 | // @codeCoverageIgnoreEnd |
349 | 349 | } |
350 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
350 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string|null $role one of the Role::* constants |
356 | 356 | * @return array[] list of parameters as accepted by Message::params() |
357 | 357 | */ |
358 | - private function renderConstraintScopeList( array $scopeList, $role ) { |
|
359 | - return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] ); |
|
358 | + private function renderConstraintScopeList(array $scopeList, $role) { |
|
359 | + return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -364,25 +364,25 @@ discard block |
||
364 | 364 | * @param string|null $role one of the Role::* constants |
365 | 365 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
366 | 366 | */ |
367 | - private function renderPropertyScope( $scope, $role ) { |
|
368 | - switch ( $scope ) { |
|
367 | + private function renderPropertyScope($scope, $role) { |
|
368 | + switch ($scope) { |
|
369 | 369 | case Context::TYPE_STATEMENT: |
370 | - $itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' ); |
|
370 | + $itemId = $this->config->get('WBQualityConstraintsAsMainValueId'); |
|
371 | 371 | break; |
372 | 372 | case Context::TYPE_QUALIFIER: |
373 | - $itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' ); |
|
373 | + $itemId = $this->config->get('WBQualityConstraintsAsQualifiersId'); |
|
374 | 374 | break; |
375 | 375 | case Context::TYPE_REFERENCE: |
376 | - $itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' ); |
|
376 | + $itemId = $this->config->get('WBQualityConstraintsAsReferencesId'); |
|
377 | 377 | break; |
378 | 378 | default: |
379 | 379 | // callers should never let this happen, but if it does happen, |
380 | 380 | // showing “unknown value” seems reasonable |
381 | 381 | // @codeCoverageIgnoreStart |
382 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
382 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
383 | 383 | // @codeCoverageIgnoreEnd |
384 | 384 | } |
385 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
385 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | * @param string|null $role one of the Role::* constants |
391 | 391 | * @return array[] list of parameters as accepted by Message::params() |
392 | 392 | */ |
393 | - private function renderPropertyScopeList( array $scopeList, $role ) { |
|
394 | - return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] ); |
|
393 | + private function renderPropertyScopeList(array $scopeList, $role) { |
|
394 | + return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | * @param string|null $role one of the Role::* constants |
400 | 400 | * @return array[] list of parameters as accepted by Message::params() |
401 | 401 | */ |
402 | - private function renderLanguage( $languageCode, $role ) { |
|
402 | + private function renderLanguage($languageCode, $role) { |
|
403 | 403 | return [ |
404 | - Message::plaintextParam( Language::fetchLanguageName( $languageCode ) ), |
|
405 | - Message::plaintextParam( $languageCode ), |
|
404 | + Message::plaintextParam(Language::fetchLanguageName($languageCode)), |
|
405 | + Message::plaintextParam($languageCode), |
|
406 | 406 | ]; |
407 | 407 | } |
408 | 408 |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | * @param ViolationMessage $violationMessage |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function render( ViolationMessage $violationMessage ) { |
|
58 | - if ( !array_key_exists( $violationMessage->getMessageKey(), $this->alternativeMessageKeys ) ) { |
|
59 | - return parent::render( $violationMessage ); |
|
57 | + public function render(ViolationMessage $violationMessage) { |
|
58 | + if (!array_key_exists($violationMessage->getMessageKey(), $this->alternativeMessageKeys)) { |
|
59 | + return parent::render($violationMessage); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $arguments = $violationMessage->getArguments(); |
63 | - $multilingualTextArgument = array_pop( $arguments ); |
|
63 | + $multilingualTextArgument = array_pop($arguments); |
|
64 | 64 | $multilingualTextParams = $this->renderMultilingualText( |
65 | 65 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable TODO Ensure this is not an actual issue |
66 | 66 | $multilingualTextArgument['value'], |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | $multilingualTextArgument['role'] |
69 | 69 | ); |
70 | 70 | |
71 | - $paramsLists = [ [] ]; |
|
72 | - foreach ( $arguments as $argument ) { |
|
73 | - $paramsLists[] = $this->renderArgument( $argument ); |
|
71 | + $paramsLists = [[]]; |
|
72 | + foreach ($arguments as $argument) { |
|
73 | + $paramsLists[] = $this->renderArgument($argument); |
|
74 | 74 | } |
75 | - $regularParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
75 | + $regularParams = call_user_func_array('array_merge', $paramsLists); |
|
76 | 76 | |
77 | - if ( $multilingualTextParams === null ) { |
|
77 | + if ($multilingualTextParams === null) { |
|
78 | 78 | return $this->messageLocalizer |
79 | - ->msg( $this->alternativeMessageKeys[$violationMessage->getMessageKey()] ) |
|
80 | - ->params( $regularParams ) |
|
79 | + ->msg($this->alternativeMessageKeys[$violationMessage->getMessageKey()]) |
|
80 | + ->params($regularParams) |
|
81 | 81 | ->escaped(); |
82 | 82 | } else { |
83 | 83 | return $this->messageLocalizer |
84 | - ->msg( $violationMessage->getMessageKey() ) |
|
85 | - ->params( $regularParams ) |
|
86 | - ->params( $multilingualTextParams ) |
|
84 | + ->msg($violationMessage->getMessageKey()) |
|
85 | + ->params($regularParams) |
|
86 | + ->params($multilingualTextParams) |
|
87 | 87 | ->escaped(); |
88 | 88 | } |
89 | 89 | } |
@@ -94,18 +94,18 @@ discard block |
||
94 | 94 | * @return array[]|null list of parameters as accepted by Message::params(), |
95 | 95 | * or null if the text is not available in the user’s language |
96 | 96 | */ |
97 | - protected function renderMultilingualText( MultilingualTextValue $text, $role ) { |
|
97 | + protected function renderMultilingualText(MultilingualTextValue $text, $role) { |
|
98 | 98 | global $wgLang; |
99 | 99 | $languageCodes = $wgLang->getFallbackLanguages(); |
100 | - array_unshift( $languageCodes, $wgLang->getCode() ); |
|
100 | + array_unshift($languageCodes, $wgLang->getCode()); |
|
101 | 101 | |
102 | 102 | $texts = $text->getTexts(); |
103 | - foreach ( $languageCodes as $languageCode ) { |
|
104 | - if ( array_key_exists( $languageCode, $texts ) ) { |
|
105 | - return [ Message::rawParam( $this->addRole( |
|
106 | - htmlspecialchars( $texts[$languageCode]->getText() ), |
|
103 | + foreach ($languageCodes as $languageCode) { |
|
104 | + if (array_key_exists($languageCode, $texts)) { |
|
105 | + return [Message::rawParam($this->addRole( |
|
106 | + htmlspecialchars($texts[$languageCode]->getText()), |
|
107 | 107 | $role |
108 | - ) ) ]; |
|
108 | + ))]; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 |
@@ -28,25 +28,25 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @param DatabaseUpdater $updater |
30 | 30 | */ |
31 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
31 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
32 | 32 | $updater->addExtensionTable( |
33 | 33 | 'wbqc_constraints', |
34 | - __DIR__ . '/../sql/create_wbqc_constraints.sql' |
|
34 | + __DIR__.'/../sql/create_wbqc_constraints.sql' |
|
35 | 35 | ); |
36 | 36 | $updater->addExtensionField( |
37 | 37 | 'wbqc_constraints', |
38 | 38 | 'constraint_id', |
39 | - __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
39 | + __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
40 | 40 | ); |
41 | 41 | $updater->addExtensionIndex( |
42 | 42 | 'wbqc_constraints', |
43 | 43 | 'wbqc_constraints_guid_uniq', |
44 | - __DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
44 | + __DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
45 | 45 | ); |
46 | 46 | } |
47 | 47 | |
48 | - public static function onWikibaseChange( Change $change ) { |
|
49 | - if ( !( $change instanceof EntityChange ) ) { |
|
48 | + public static function onWikibaseChange(Change $change) { |
|
49 | + if (!($change instanceof EntityChange)) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
@@ -55,48 +55,48 @@ discard block |
||
55 | 55 | |
56 | 56 | // If jobs are enabled and the results would be stored in some way run a job. |
57 | 57 | if ( |
58 | - $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) && |
|
59 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) && |
|
58 | + $config->get('WBQualityConstraintsEnableConstraintsCheckJobs') && |
|
59 | + $config->get('WBQualityConstraintsCacheCheckConstraintsResults') && |
|
60 | 60 | self::isSelectedForJobRunBasedOnPercentage() |
61 | 61 | ) { |
62 | - $params = [ 'entityId' => $change->getEntityId()->getSerialization() ]; |
|
62 | + $params = ['entityId' => $change->getEntityId()->getSerialization()]; |
|
63 | 63 | JobQueueGroup::singleton()->push( |
64 | - new JobSpecification( CheckConstraintsJob::COMMAND, $params ) |
|
64 | + new JobSpecification(CheckConstraintsJob::COMMAND, $params) |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
68 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
69 | - self::isConstraintStatementsChange( $config, $change ) |
|
68 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
69 | + self::isConstraintStatementsChange($config, $change) |
|
70 | 70 | ) { |
71 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
71 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
72 | 72 | $metadata = $change->getMetadata(); |
73 | - if ( array_key_exists( 'rev_id', $metadata ) ) { |
|
73 | + if (array_key_exists('rev_id', $metadata)) { |
|
74 | 74 | $params['revisionId'] = $metadata['rev_id']; |
75 | 75 | } |
76 | 76 | JobQueueGroup::singleton()->push( |
77 | - new JobSpecification( 'constraintsTableUpdate', $params ) |
|
77 | + new JobSpecification('constraintsTableUpdate', $params) |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | private static function isSelectedForJobRunBasedOnPercentage() { |
83 | 83 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
84 | - $percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' ); |
|
84 | + $percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio'); |
|
85 | 85 | |
86 | - return mt_rand( 1, 100 ) <= $percentage; |
|
86 | + return mt_rand(1, 100) <= $percentage; |
|
87 | 87 | } |
88 | 88 | |
89 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
90 | - if ( !( $change instanceof EntityChange ) || |
|
89 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
90 | + if (!($change instanceof EntityChange) || |
|
91 | 91 | $change->getAction() !== EntityChange::UPDATE || |
92 | - !( $change->getEntityId() instanceof PropertyId ) |
|
92 | + !($change->getEntityId() instanceof PropertyId) |
|
93 | 93 | ) { |
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $info = $change->getInfo(); |
98 | 98 | |
99 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
99 | + if (!array_key_exists('compactDiff', $info)) { |
|
100 | 100 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
101 | 101 | // so we only know that the change *might* affect the constraint statements |
102 | 102 | return true; |
@@ -105,47 +105,47 @@ discard block |
||
105 | 105 | /** @var EntityDiffChangedAspects $aspects */ |
106 | 106 | $aspects = $info['compactDiff']; |
107 | 107 | |
108 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
109 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
108 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
109 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
110 | 110 | } |
111 | 111 | |
112 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
112 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
113 | 113 | $repo = WikibaseRepo::getDefaultInstance(); |
114 | 114 | |
115 | 115 | $entityContentFactory = $repo->getEntityContentFactory(); |
116 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
116 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
117 | 117 | $entityIdLookup = $repo->getEntityIdLookup(); |
118 | - $entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
119 | - if ( $entityId !== null ) { |
|
118 | + $entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle()); |
|
119 | + if ($entityId !== null) { |
|
120 | 120 | $resultsCache = ResultsCache::getDefaultInstance(); |
121 | - $resultsCache->delete( $entityId ); |
|
121 | + $resultsCache->delete($entityId); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
126 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
127 | 127 | $repo = WikibaseRepo::getDefaultInstance(); |
128 | 128 | |
129 | 129 | $lookup = $repo->getEntityNamespaceLookup(); |
130 | 130 | $title = $out->getTitle(); |
131 | - if ( $title === null ) { |
|
131 | + if ($title === null) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | - if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) { |
|
135 | + if (!$lookup->isNamespaceWithEntities($title->getNamespace())) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
138 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
142 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
143 | 143 | |
144 | - if ( !$out->getUser()->isRegistered() ) { |
|
144 | + if (!$out->getUser()->isRegistered()) { |
|
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
148 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
@@ -28,46 +28,46 @@ discard block |
||
28 | 28 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
29 | 29 | |
30 | 30 | return [ |
31 | - ConstraintsServices::EXPIRY_LOCK => function ( MediaWikiServices $services ) { |
|
32 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
31 | + ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) { |
|
32 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
33 | 33 | }, |
34 | 34 | |
35 | - ConstraintsServices::LOGGING_HELPER => function ( MediaWikiServices $services ) { |
|
35 | + ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) { |
|
36 | 36 | return new LoggingHelper( |
37 | 37 | $services->getStatsdDataFactory(), |
38 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
38 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
39 | 39 | $services->getMainConfig() |
40 | 40 | ); |
41 | 41 | }, |
42 | 42 | |
43 | - ConstraintsServices::CONSTRAINT_STORE => function ( MediaWikiServices $services ) { |
|
43 | + ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) { |
|
44 | 44 | $wbRepo = WikibaseRepo::getDefaultInstance(); |
45 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
46 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
45 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
46 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
47 | 47 | $dbName = $propertySource->getDatabaseName(); |
48 | 48 | |
49 | - if ( $propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName() ) { |
|
50 | - throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
49 | + if ($propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName()) { |
|
50 | + throw new \RuntimeException('Can\'t get a ConstraintStore for a non local entity source.'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | return new ConstraintRepositoryStore( |
54 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
54 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
55 | 55 | $dbName |
56 | 56 | ); |
57 | 57 | }, |
58 | 58 | |
59 | - ConstraintsServices::CONSTRAINT_LOOKUP => function ( MediaWikiServices $services ) { |
|
60 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
61 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
59 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
60 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
61 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
62 | 62 | $dbName = $propertySource->getDatabaseName(); |
63 | 63 | $rawLookup = new ConstraintRepositoryLookup( |
64 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
64 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
65 | 65 | $dbName |
66 | 66 | ); |
67 | - return new CachingConstraintLookup( $rawLookup ); |
|
67 | + return new CachingConstraintLookup($rawLookup); |
|
68 | 68 | }, |
69 | 69 | |
70 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function ( MediaWikiServices $services ) { |
|
70 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
71 | 71 | return new CheckResultSerializer( |
72 | 72 | new ConstraintSerializer( |
73 | 73 | false // constraint parameters are not exposed |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | ); |
79 | 79 | }, |
80 | 80 | |
81 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function ( MediaWikiServices $services ) { |
|
81 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
82 | 82 | // TODO in the future, get DataValueFactory from $services? |
83 | 83 | $repo = WikibaseRepo::getDefaultInstance(); |
84 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
84 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
85 | 85 | $dataValueFactory = $repo->getDataValueFactory(); |
86 | 86 | |
87 | 87 | return new CheckResultDeserializer( |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | ); |
96 | 96 | }, |
97 | 97 | |
98 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function ( MediaWikiServices $services ) { |
|
98 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
99 | 99 | return new ViolationMessageSerializer(); |
100 | 100 | }, |
101 | 101 | |
102 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function ( MediaWikiServices $services ) { |
|
102 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
103 | 103 | // TODO in the future, get DataValueFactory from $services? |
104 | 104 | $repo = WikibaseRepo::getDefaultInstance(); |
105 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
105 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
106 | 106 | $dataValueFactory = $repo->getDataValueFactory(); |
107 | 107 | |
108 | 108 | return new ViolationMessageDeserializer( |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | ); |
112 | 112 | }, |
113 | 113 | |
114 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function ( MediaWikiServices $services ) { |
|
114 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
115 | 115 | // TODO in the future, get DeserializerFactory from $services? |
116 | 116 | $repo = WikibaseRepo::getDefaultInstance(); |
117 | 117 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
118 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
118 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
119 | 119 | |
120 | 120 | return new ConstraintParameterParser( |
121 | 121 | $services->getMainConfig(), |
122 | 122 | $deserializerFactory, |
123 | - $entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri() |
|
123 | + $entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri() |
|
124 | 124 | ); |
125 | 125 | }, |
126 | 126 | |
127 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
127 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
128 | 128 | return new ConnectionCheckerHelper(); |
129 | 129 | }, |
130 | 130 | |
131 | - ConstraintsServices::RANGE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
131 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
132 | 132 | // TODO in the future, get UnitConverter from $services? |
133 | 133 | $repo = WikibaseRepo::getDefaultInstance(); |
134 | 134 | $unitConverter = $repo->getUnitConverter(); |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | ); |
140 | 140 | }, |
141 | 141 | |
142 | - ConstraintsServices::SPARQL_HELPER => function ( MediaWikiServices $services ) { |
|
143 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
144 | - if ( $endpoint === '' ) { |
|
142 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
143 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
144 | + if ($endpoint === '') { |
|
145 | 145 | return new DummySparqlHelper(); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // TODO in the future, get RDFVocabulary and PropertyDataTypeLookup from $services? |
149 | 149 | $repo = WikibaseRepo::getDefaultInstance(); |
150 | 150 | $rdfVocabulary = $repo->getRdfVocabulary(); |
151 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
151 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
152 | 152 | $propertyDataTypeLookup = $repo->getPropertyDataTypeLookup(); |
153 | 153 | |
154 | 154 | return new SparqlHelper( |
@@ -157,123 +157,123 @@ discard block |
||
157 | 157 | $entityIdParser, |
158 | 158 | $propertyDataTypeLookup, |
159 | 159 | $services->getMainWANObjectCache(), |
160 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
161 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
160 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
161 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
162 | 162 | $services->getStatsdDataFactory(), |
163 | - ConstraintsServices::getExpiryLock( $services ), |
|
163 | + ConstraintsServices::getExpiryLock($services), |
|
164 | 164 | ConstraintsServices::getLoggingHelper(), |
165 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
165 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
166 | 166 | $services->getHttpRequestFactory() |
167 | 167 | ); |
168 | 168 | }, |
169 | 169 | |
170 | - ConstraintsServices::TYPE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
170 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
171 | 171 | return new TypeCheckerHelper( |
172 | - WikibaseServices::getEntityLookup( $services ), |
|
172 | + WikibaseServices::getEntityLookup($services), |
|
173 | 173 | $services->getMainConfig(), |
174 | - ConstraintsServices::getSparqlHelper( $services ), |
|
174 | + ConstraintsServices::getSparqlHelper($services), |
|
175 | 175 | $services->getStatsdDataFactory() |
176 | 176 | ); |
177 | 177 | }, |
178 | 178 | |
179 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function ( MediaWikiServices $services ) { |
|
179 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
180 | 180 | // TODO in the future, get StatementGuidParser from $services? |
181 | 181 | $repo = WikibaseRepo::getDefaultInstance(); |
182 | 182 | $statementGuidParser = $repo->getStatementGuidParser(); |
183 | 183 | |
184 | 184 | $config = $services->getMainConfig(); |
185 | 185 | $checkerMap = [ |
186 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
187 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
188 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
189 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
190 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
191 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
192 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
193 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
194 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
195 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
196 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
197 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
198 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
199 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
200 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
201 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
202 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
203 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
204 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
205 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
206 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
207 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
208 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
209 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
210 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
211 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
212 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
213 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
214 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
215 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
216 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
217 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
218 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
219 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
220 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
221 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
222 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
223 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
224 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
225 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
226 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
227 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
228 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
229 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
230 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
231 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
232 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
233 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
234 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
235 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
236 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
237 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
238 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
239 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
240 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
241 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
242 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
243 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
186 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
187 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
188 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
189 | + => ConstraintCheckerServices::getItemChecker($services), |
|
190 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
191 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
192 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
193 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
194 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
195 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
196 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
197 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
198 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
199 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
200 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
201 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
202 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
203 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
204 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
205 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
206 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
207 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
208 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
209 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
210 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
211 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
212 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
213 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
214 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
215 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
216 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
217 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
218 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
219 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
220 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
221 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
222 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
223 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
224 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
225 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
226 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
227 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
228 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
229 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
230 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
231 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
232 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
233 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
234 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
235 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
236 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
237 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
238 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
239 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
240 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
241 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
242 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
243 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
244 | 244 | ]; |
245 | 245 | |
246 | 246 | return new DelegatingConstraintChecker( |
247 | - WikibaseServices::getEntityLookup( $services ), |
|
247 | + WikibaseServices::getEntityLookup($services), |
|
248 | 248 | $checkerMap, |
249 | - ConstraintsServices::getConstraintLookup( $services ), |
|
250 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
249 | + ConstraintsServices::getConstraintLookup($services), |
|
250 | + ConstraintsServices::getConstraintParameterParser($services), |
|
251 | 251 | $statementGuidParser, |
252 | - ConstraintsServices::getLoggingHelper( $services ), |
|
253 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
254 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
255 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
252 | + ConstraintsServices::getLoggingHelper($services), |
|
253 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
254 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
255 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
256 | 256 | ); |
257 | 257 | }, |
258 | 258 | |
259 | - ConstraintsServices::RESULTS_SOURCE => function ( MediaWikiServices $services ) { |
|
259 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
260 | 260 | $config = $services->getMainConfig(); |
261 | 261 | $resultsSource = new CheckingResultsSource( |
262 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
262 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
263 | 263 | ); |
264 | 264 | |
265 | 265 | $cacheCheckConstraintsResults = false; |
266 | 266 | |
267 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
267 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
268 | 268 | $cacheCheckConstraintsResults = true; |
269 | 269 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
270 | 270 | // TODO we should always be able to cache constraint check results (T244726) |
271 | 271 | $repo = WikibaseRepo::getDefaultInstance(); |
272 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
273 | - foreach ( $entitySources as $entitySource ) { |
|
274 | - if ( $entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName() ) { |
|
275 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
276 | - 'Cannot cache constraint check results for non-local source: ' . |
|
272 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
273 | + foreach ($entitySources as $entitySource) { |
|
274 | + if ($entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName()) { |
|
275 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
276 | + 'Cannot cache constraint check results for non-local source: '. |
|
277 | 277 | $entitySource->getSourceName() |
278 | 278 | ); |
279 | 279 | $cacheCheckConstraintsResults = false; |
@@ -282,29 +282,29 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | - if ( $cacheCheckConstraintsResults ) { |
|
285 | + if ($cacheCheckConstraintsResults) { |
|
286 | 286 | $possiblyStaleConstraintTypes = [ |
287 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
288 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
289 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
290 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
287 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
288 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
289 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
290 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
291 | 291 | ]; |
292 | 292 | // TODO in the future, get WikiPageEntityMetaDataAccessor from $services? |
293 | 293 | $repo = WikibaseRepo::getDefaultInstance(); |
294 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
294 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
295 | 295 | $wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor(); |
296 | 296 | |
297 | 297 | $resultsSource = new CachingResultsSource( |
298 | 298 | $resultsSource, |
299 | 299 | ResultsCache::getDefaultInstance(), |
300 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
301 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
300 | + ConstraintsServices::getCheckResultSerializer($services), |
|
301 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
302 | 302 | $wikiPageEntityMetaDataAccessor, |
303 | 303 | $entityIdParser, |
304 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
304 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
305 | 305 | $possiblyStaleConstraintTypes, |
306 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
307 | - ConstraintsServices::getLoggingHelper( $services ) |
|
306 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
307 | + ConstraintsServices::getLoggingHelper($services) |
|
308 | 308 | ); |
309 | 309 | } |
310 | 310 |