Completed
Push — master ( 08de92...05461e )
by
unknown
39s queued 14s
created
src/ConstraintCheck/Helper/SparqlHelper.php 1 patch
Spacing   +203 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Helper;
6 6
 
@@ -166,143 +166,143 @@  discard block
 block discarded – undo
166 166
 		$this->defaultUserAgent = $defaultUserAgent;
167 167
 		$this->requestFactory = $requestFactory;
168 168
 		$this->entityPrefixes = [];
169
-		foreach ( $rdfVocabulary->entityNamespaceNames as $namespaceName ) {
170
-			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI( $namespaceName );
169
+		foreach ($rdfVocabulary->entityNamespaceNames as $namespaceName) {
170
+			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI($namespaceName);
171 171
 		}
172 172
 
173
-		$this->primaryEndpoint = $config->get( 'WBQualityConstraintsSparqlEndpoint' );
174
-		$this->additionalEndpoints = $config->get( 'WBQualityConstraintsAdditionalSparqlEndpoints' ) ?: [];
175
-		$this->maxQueryTimeMillis = $config->get( 'WBQualityConstraintsSparqlMaxMillis' );
176
-		$this->subclassOfId = new NumericPropertyId( $config->get( 'WBQualityConstraintsSubclassOfId' ) );
177
-		$this->cacheMapSize = $config->get( 'WBQualityConstraintsFormatCacheMapSize' );
173
+		$this->primaryEndpoint = $config->get('WBQualityConstraintsSparqlEndpoint');
174
+		$this->additionalEndpoints = $config->get('WBQualityConstraintsAdditionalSparqlEndpoints') ?: [];
175
+		$this->maxQueryTimeMillis = $config->get('WBQualityConstraintsSparqlMaxMillis');
176
+		$this->subclassOfId = new NumericPropertyId($config->get('WBQualityConstraintsSubclassOfId'));
177
+		$this->cacheMapSize = $config->get('WBQualityConstraintsFormatCacheMapSize');
178 178
 		$this->timeoutExceptionClasses = $config->get(
179 179
 			'WBQualityConstraintsSparqlTimeoutExceptionClasses'
180 180
 		);
181 181
 		$this->sparqlHasWikibaseSupport = $config->get(
182 182
 			'WBQualityConstraintsSparqlHasWikibaseSupport'
183 183
 		);
184
-		$this->sparqlThrottlingFallbackDuration = (int)$config->get(
184
+		$this->sparqlThrottlingFallbackDuration = (int) $config->get(
185 185
 			'WBQualityConstraintsSparqlThrottlingFallbackDuration'
186 186
 		);
187 187
 
188
-		$this->prefixes = $this->getQueryPrefixes( $rdfVocabulary );
188
+		$this->prefixes = $this->getQueryPrefixes($rdfVocabulary);
189 189
 
190 190
 		$this->rdfVocabularyWithoutNormalization = clone $rdfVocabulary;
191 191
 		// @phan-suppress-next-line PhanTypeMismatchProperty
192 192
 		$this->rdfVocabularyWithoutNormalization->normalizedPropertyValueNamespace = array_fill_keys(
193
-			array_keys( $rdfVocabulary->normalizedPropertyValueNamespace ),
193
+			array_keys($rdfVocabulary->normalizedPropertyValueNamespace),
194 194
 			null
195 195
 		);
196 196
 	}
197 197
 
198
-	private function getQueryPrefixes( RdfVocabulary $rdfVocabulary ): string {
198
+	private function getQueryPrefixes(RdfVocabulary $rdfVocabulary): string {
199 199
 		// TODO: it would probably be smarter that RdfVocabulary exposed these prefixes somehow
200 200
 		$prefixes = '';
201
-		foreach ( $rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName ) {
201
+		foreach ($rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName) {
202 202
 			$prefixes .= <<<END
203
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
203
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
204 204
 END;
205 205
 		}
206 206
 
207
-		foreach ( $rdfVocabulary->statementNamespaceNames as $sourceName => $sourceNamespaces ) {
207
+		foreach ($rdfVocabulary->statementNamespaceNames as $sourceName => $sourceNamespaces) {
208 208
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NS_VALUE];
209 209
 			$prefixes .= <<<END
210
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
210
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
211 211
 END;
212 212
 		}
213 213
 
214
-		foreach ( $rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces ) {
214
+		foreach ($rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces) {
215 215
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_DIRECT_CLAIM];
216 216
 			$prefixes .= <<<END
217
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
217
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
218 218
 END;
219 219
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM];
220 220
 			$prefixes .= <<<END
221
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
221
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
222 222
 END;
223 223
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_STATEMENT];
224 224
 			$prefixes .= <<<END
225
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
225
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
226 226
 END;
227 227
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_VALUE];
228 228
 			$prefixes .= <<<END
229
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
229
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
230 230
 END;
231 231
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER];
232 232
 			$prefixes .= <<<END
233
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
233
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
234 234
 END;
235 235
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER_VALUE];
236 236
 			$prefixes .= <<<END
237
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
237
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
238 238
 END;
239 239
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE];
240 240
 			$prefixes .= <<<END
241
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
241
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
242 242
 END;
243 243
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE_VALUE];
244 244
 			$prefixes .= <<<END
245
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
245
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
246 246
 END;
247 247
 		}
248 248
 		$namespaceName = RdfVocabulary::NS_ONTOLOGY;
249 249
 		$prefixes .= <<<END
250
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
250
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
251 251
 END;
252 252
 		return $prefixes;
253 253
 	}
254 254
 
255 255
 	/** Return a SPARQL term like `wd:Q123` for the given ID. */
256
-	private function wd( EntityId $id ): string {
257
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
256
+	private function wd(EntityId $id): string {
257
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
258 258
 		$prefix = $this->rdfVocabulary->entityNamespaceNames[$repository];
259 259
 		return "$prefix:{$id->getSerialization()}";
260 260
 	}
261 261
 
262 262
 	/** Return a SPARQL term like `wdt:P123` for the given ID. */
263
-	private function wdt( PropertyId $id ): string {
264
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
263
+	private function wdt(PropertyId $id): string {
264
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
265 265
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_DIRECT_CLAIM];
266 266
 		return "$prefix:{$id->getSerialization()}";
267 267
 	}
268 268
 
269 269
 	/** Return a SPARQL term like `p:P123` for the given ID. */
270
-	private function p( PropertyId $id ): string {
271
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
270
+	private function p(PropertyId $id): string {
271
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
272 272
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_CLAIM];
273 273
 		return "$prefix:{$id->getSerialization()}";
274 274
 	}
275 275
 
276 276
 	/** Return a SPARQL term like `pq:P123` for the given ID. */
277
-	private function pq( PropertyId $id ): string {
278
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
277
+	private function pq(PropertyId $id): string {
278
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
279 279
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_QUALIFIER];
280 280
 		return "$prefix:{$id->getSerialization()}";
281 281
 	}
282 282
 
283 283
 	/** Return a SPARQL term like `wdno:P123` for the given ID. */
284
-	private function wdno( PropertyId $id ): string {
285
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
284
+	private function wdno(PropertyId $id): string {
285
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
286 286
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_NOVALUE];
287 287
 		return "$prefix:{$id->getSerialization()}";
288 288
 	}
289 289
 
290 290
 	/** Return a SPARQL term like `prov:NAME` for the given name. */
291
-	private function prov( string $name ): string {
291
+	private function prov(string $name): string {
292 292
 		$prefix = RdfVocabulary::NS_PROV;
293 293
 		return "$prefix:$name";
294 294
 	}
295 295
 
296 296
 	/** Return a SPARQL term like `wikibase:NAME` for the given name. */
297
-	private function wikibase( string $name ): string {
297
+	private function wikibase(string $name): string {
298 298
 		$prefix = RdfVocabulary::NS_ONTOLOGY;
299 299
 		return "$prefix:$name";
300 300
 	}
301 301
 
302 302
 	/** Return a SPARQL snippet like `MINUS { ?var wikibase:rank wikibase:DeprecatedRank. }`. */
303
-	private function minusDeprecatedRank( string $varName ): string {
303
+	private function minusDeprecatedRank(string $varName): string {
304 304
 		$deprecatedRank = RdfVocabulary::RANK_MAP[Statement::RANK_DEPRECATED];
305
-		return "MINUS { $varName {$this->wikibase( 'rank' )} {$this->wikibase( $deprecatedRank )}. }";
305
+		return "MINUS { $varName {$this->wikibase('rank')} {$this->wikibase($deprecatedRank)}. }";
306 306
 	}
307 307
 
308 308
 	/**
@@ -312,43 +312,42 @@  discard block
 block discarded – undo
312 312
 	 * @return CachedBool
313 313
 	 * @throws SparqlHelperException if the query times out or some other error occurs
314 314
 	 */
315
-	public function hasType( EntityId $id, array $classes ): CachedBool {
315
+	public function hasType(EntityId $id, array $classes): CachedBool {
316 316
 		// TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually
317 317
 		$gearingHint = $this->sparqlHasWikibaseSupport ?
318
-			' hint:Prior hint:gearing "forward".' :
319
-			'';
318
+			' hint:Prior hint:gearing "forward".' : '';
320 319
 
321 320
 		$metadatas = [];
322 321
 
323
-		foreach ( array_chunk( $classes, 20 ) as $classesChunk ) {
324
-			$classesValues = implode( ' ', array_map(
325
-				function ( string $class ) {
326
-					return $this->wd( new ItemId( $class ) );
322
+		foreach (array_chunk($classes, 20) as $classesChunk) {
323
+			$classesValues = implode(' ', array_map(
324
+				function(string $class) {
325
+					return $this->wd(new ItemId($class));
327 326
 				},
328 327
 				$classesChunk
329
-			) );
328
+			));
330 329
 
331 330
 			$query = <<<EOF
332 331
 ASK {
333
-  BIND({$this->wd( $id )} AS ?item)
332
+  BIND({$this->wd($id)} AS ?item)
334 333
   VALUES ?class { $classesValues }
335
-  ?item {$this->wdt( $this->subclassOfId )}* ?class.$gearingHint
334
+  ?item {$this->wdt($this->subclassOfId)}* ?class.$gearingHint
336 335
 }
337 336
 EOF;
338 337
 
339
-			$result = $this->runQuery( $query, $this->primaryEndpoint );
338
+			$result = $this->runQuery($query, $this->primaryEndpoint);
340 339
 			$metadatas[] = $result->getMetadata();
341
-			if ( $result->getArray()['boolean'] ) {
340
+			if ($result->getArray()['boolean']) {
342 341
 				return new CachedBool(
343 342
 					true,
344
-					Metadata::merge( $metadatas )
343
+					Metadata::merge($metadatas)
345 344
 				);
346 345
 			}
347 346
 		}
348 347
 
349 348
 		return new CachedBool(
350 349
 			false,
351
-			Metadata::merge( $metadatas )
350
+			Metadata::merge($metadatas)
352 351
 		);
353 352
 	}
354 353
 
@@ -365,12 +364,12 @@  discard block
 block discarded – undo
365 364
 		array $separators
366 365
 	): CachedEntityIds {
367 366
 		$mainSnak = $statement->getMainSnak();
368
-		if ( !( $mainSnak instanceof PropertyValueSnak ) ) {
369
-			return new CachedEntityIds( [], Metadata::blank() );
367
+		if (!($mainSnak instanceof PropertyValueSnak)) {
368
+			return new CachedEntityIds([], Metadata::blank());
370 369
 		}
371 370
 
372 371
 		$propertyId = $statement->getPropertyId();
373
-		$pPredicateAndObject = "{$this->p( $propertyId )} ?otherStatement."; // p:P123 ?otherStatement.
372
+		$pPredicateAndObject = "{$this->p($propertyId)} ?otherStatement."; // p:P123 ?otherStatement.
374 373
 		$otherStatementPredicateAndObject = $this->getSnakPredicateAndObject(
375 374
 			$entityId,
376 375
 			$mainSnak,
@@ -379,57 +378,57 @@  discard block
 block discarded – undo
379 378
 
380 379
 		$isSeparator = [];
381 380
 		$unusedSeparators = [];
382
-		foreach ( $separators as $separator ) {
381
+		foreach ($separators as $separator) {
383 382
 			$isSeparator[$separator->getSerialization()] = true;
384 383
 			$unusedSeparators[$separator->getSerialization()] = $separator;
385 384
 		}
386 385
 		$separatorFilters = '';
387
-		foreach ( $statement->getQualifiers() as $qualifier ) {
386
+		foreach ($statement->getQualifiers() as $qualifier) {
388 387
 			$qualPropertyId = $qualifier->getPropertyId();
389
-			if ( !( $isSeparator[$qualPropertyId->getSerialization()] ?? false ) ) {
388
+			if (!($isSeparator[$qualPropertyId->getSerialization()] ?? false)) {
390 389
 				continue;
391 390
 			}
392
-			unset( $unusedSeparators[$qualPropertyId->getSerialization()] );
391
+			unset($unusedSeparators[$qualPropertyId->getSerialization()]);
393 392
 			// only look for other statements with the same qualifier
394
-			if ( $qualifier instanceof PropertyValueSnak ) {
393
+			if ($qualifier instanceof PropertyValueSnak) {
395 394
 				$sepPredicateAndObject = $this->getSnakPredicateAndObject(
396 395
 					$entityId,
397 396
 					$qualifier,
398 397
 					RdfVocabulary::NSP_QUALIFIER
399 398
 				);
400 399
 				$separatorFilters .= "  ?otherStatement $sepPredicateAndObject\n";
401
-			} elseif ( $qualifier instanceof PropertyNoValueSnak ) {
402
-				$sepPredicateAndObject = "a {$this->wdno( $qualPropertyId )}."; // a wdno:P123.
400
+			} elseif ($qualifier instanceof PropertyNoValueSnak) {
401
+				$sepPredicateAndObject = "a {$this->wdno($qualPropertyId)}."; // a wdno:P123.
403 402
 				$separatorFilters .= "  ?otherStatement $sepPredicateAndObject\n";
404 403
 			} else {
405 404
 				// "some value" / "unknown value" is always different from everything else,
406 405
 				// therefore the whole statement has no duplicates and we can return immediately
407
-				return new CachedEntityIds( [], Metadata::blank() );
406
+				return new CachedEntityIds([], Metadata::blank());
408 407
 			}
409 408
 		}
410
-		foreach ( $unusedSeparators as $unusedSeparator ) {
409
+		foreach ($unusedSeparators as $unusedSeparator) {
411 410
 			// exclude other statements which have a separator that this one lacks
412
-			$separatorFilters .= "  MINUS { ?otherStatement {$this->pq( $unusedSeparator )} []. }\n";
413
-			$separatorFilters .= "  MINUS { ?otherStatement a {$this->wdno( $unusedSeparator )}. }\n";
411
+			$separatorFilters .= "  MINUS { ?otherStatement {$this->pq($unusedSeparator)} []. }\n";
412
+			$separatorFilters .= "  MINUS { ?otherStatement a {$this->wdno($unusedSeparator)}. }\n";
414 413
 		}
415 414
 
416 415
 		$query = <<<SPARQL
417 416
 SELECT DISTINCT ?otherEntity WHERE {
418 417
   ?otherEntity $pPredicateAndObject
419 418
   ?otherStatement $otherStatementPredicateAndObject
420
-  {$this->minusDeprecatedRank( '?otherStatement' )}
421
-  FILTER(?otherEntity != {$this->wd( $entityId )})
419
+  {$this->minusDeprecatedRank('?otherStatement')}
420
+  FILTER(?otherEntity != {$this->wd($entityId)})
422 421
 $separatorFilters
423 422
 }
424 423
 LIMIT 10
425 424
 SPARQL;
426 425
 
427
-		$results = [ $this->runQuery( $query, $this->primaryEndpoint ) ];
428
-		foreach ( $this->additionalEndpoints as $endpoint ) {
429
-			$results[] = $this->runQuery( $query, $endpoint );
426
+		$results = [$this->runQuery($query, $this->primaryEndpoint)];
427
+		foreach ($this->additionalEndpoints as $endpoint) {
428
+			$results[] = $this->runQuery($query, $endpoint);
430 429
 		}
431 430
 
432
-		return $this->getOtherEntities( $results );
431
+		return $this->getOtherEntities($results);
433 432
 	}
434 433
 
435 434
 	/**
@@ -448,40 +447,38 @@  discard block
 block discarded – undo
448 447
 		bool $ignoreDeprecatedStatements
449 448
 	): CachedEntityIds {
450 449
 		$propertyId = $snak->getPropertyId();
451
-		$pPredicateAndObject = "{$this->p( $propertyId )} ?otherStatement."; // p:P123 ?otherStatement.
450
+		$pPredicateAndObject = "{$this->p($propertyId)} ?otherStatement."; // p:P123 ?otherStatement.
452 451
 
453 452
 		$otherSubject = $type === Context::TYPE_QUALIFIER ?
454
-			'?otherStatement' :
455
-			"?otherStatement {$this->prov( 'wasDerivedFrom' )} ?reference.\n  ?reference";
453
+			'?otherStatement' : "?otherStatement {$this->prov('wasDerivedFrom')} ?reference.\n  ?reference";
456 454
 		$otherPredicateAndObject = $this->getSnakPredicateAndObject(
457 455
 			$entityId,
458 456
 			$snak,
459 457
 			$type === Context::TYPE_QUALIFIER ?
460
-				RdfVocabulary::NSP_QUALIFIER :
461
-				RdfVocabulary::NSP_REFERENCE
458
+				RdfVocabulary::NSP_QUALIFIER : RdfVocabulary::NSP_REFERENCE
462 459
 		);
463 460
 
464 461
 		$deprecatedFilter = '';
465
-		if ( $ignoreDeprecatedStatements ) {
466
-			$deprecatedFilter = '  ' . $this->minusDeprecatedRank( '?otherStatement' );
462
+		if ($ignoreDeprecatedStatements) {
463
+			$deprecatedFilter = '  '.$this->minusDeprecatedRank('?otherStatement');
467 464
 		}
468 465
 
469 466
 		$query = <<<SPARQL
470 467
 SELECT DISTINCT ?otherEntity WHERE {
471 468
   ?otherEntity $pPredicateAndObject
472 469
   $otherSubject $otherPredicateAndObject
473
-  FILTER(?otherEntity != {$this->wd( $entityId )})
470
+  FILTER(?otherEntity != {$this->wd($entityId)})
474 471
 $deprecatedFilter
475 472
 }
476 473
 LIMIT 10
477 474
 SPARQL;
478 475
 
479
-		$results = [ $this->runQuery( $query, $this->primaryEndpoint ) ];
480
-		foreach ( $this->additionalEndpoints as $endpoint ) {
481
-			$results[] = $this->runQuery( $query, $endpoint );
476
+		$results = [$this->runQuery($query, $this->primaryEndpoint)];
477
+		foreach ($this->additionalEndpoints as $endpoint) {
478
+			$results[] = $this->runQuery($query, $endpoint);
482 479
 		}
483 480
 
484
-		return $this->getOtherEntities( $results );
481
+		return $this->getOtherEntities($results);
485 482
 	}
486 483
 
487 484
 	/**
@@ -512,13 +509,13 @@  discard block
 block discarded – undo
512 509
 		$writer->start();
513 510
 		$writer->drain();
514 511
 		$placeholder1 = 'wbqc';
515
-		$placeholder2 = 'x' . wfRandomString( 32 );
516
-		$writer->about( $placeholder1, $placeholder2 );
512
+		$placeholder2 = 'x'.wfRandomString(32);
513
+		$writer->about($placeholder1, $placeholder2);
517 514
 
518 515
 		$propertyId = $snak->getPropertyId();
519 516
 		$pid = $propertyId->getSerialization();
520
-		$propertyRepository = $this->rdfVocabulary->getEntityRepositoryName( $propertyId );
521
-		$entityRepository = $this->rdfVocabulary->getEntityRepositoryName( $entityId );
517
+		$propertyRepository = $this->rdfVocabulary->getEntityRepositoryName($propertyId);
518
+		$entityRepository = $this->rdfVocabulary->getEntityRepositoryName($entityId);
522 519
 		$propertyNamespace = $this->rdfVocabulary->propertyNamespaceNames[$propertyRepository][$namespace];
523 520
 		$value = $snak->getDataValue();
524 521
 		if (
@@ -549,21 +546,21 @@  discard block
 block discarded – undo
549 546
 				$writer,
550 547
 				$propertyNamespace,
551 548
 				$pid,
552
-				$this->propertyDataTypeLookup->getDataTypeIdForProperty( $propertyId ),
549
+				$this->propertyDataTypeLookup->getDataTypeIdForProperty($propertyId),
553 550
 				$this->rdfVocabulary->statementNamespaceNames[$entityRepository][RdfVocabulary::NS_VALUE], // should be unused
554 551
 				$snak
555 552
 			);
556 553
 		}
557 554
 
558 555
 		$triple = $writer->drain(); // wbqc:xRANDOM ps:PID "value". or similar
559
-		return trim( str_replace( "$placeholder1:$placeholder2", '', $triple ) );
556
+		return trim(str_replace("$placeholder1:$placeholder2", '', $triple));
560 557
 	}
561 558
 
562 559
 	/**
563 560
 	 * Return SPARQL code for a string literal with $text as content.
564 561
 	 */
565
-	private function stringLiteral( string $text ): string {
566
-		return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"';
562
+	private function stringLiteral(string $text): string {
563
+		return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"';
567 564
 	}
568 565
 
569 566
 	/**
@@ -573,26 +570,26 @@  discard block
 block discarded – undo
573 570
 	 *
574 571
 	 * @return CachedEntityIds
575 572
 	 */
576
-	private function getOtherEntities( array $results ): CachedEntityIds {
573
+	private function getOtherEntities(array $results): CachedEntityIds {
577 574
 		$allResultBindings = [];
578 575
 		$metadatas = [];
579 576
 
580
-		foreach ( $results as $result ) {
577
+		foreach ($results as $result) {
581 578
 			$metadatas[] = $result->getMetadata();
582
-			$allResultBindings = array_merge( $allResultBindings, $result->getArray()['results']['bindings'] );
579
+			$allResultBindings = array_merge($allResultBindings, $result->getArray()['results']['bindings']);
583 580
 		}
584 581
 
585 582
 		$entityIds = array_map(
586
-			function ( $resultBindings ) {
583
+			function($resultBindings) {
587 584
 				$entityIRI = $resultBindings['otherEntity']['value'];
588
-				foreach ( $this->entityPrefixes as $entityPrefix ) {
589
-					$entityPrefixLength = strlen( $entityPrefix );
590
-					if ( substr( $entityIRI, 0, $entityPrefixLength ) === $entityPrefix ) {
585
+				foreach ($this->entityPrefixes as $entityPrefix) {
586
+					$entityPrefixLength = strlen($entityPrefix);
587
+					if (substr($entityIRI, 0, $entityPrefixLength) === $entityPrefix) {
591 588
 						try {
592 589
 							return $this->entityIdParser->parse(
593
-								substr( $entityIRI, $entityPrefixLength )
590
+								substr($entityIRI, $entityPrefixLength)
594 591
 							);
595
-						} catch ( EntityIdParsingException $e ) {
592
+						} catch (EntityIdParsingException $e) {
596 593
 							// fall through
597 594
 						}
598 595
 					}
@@ -606,8 +603,8 @@  discard block
 block discarded – undo
606 603
 		);
607 604
 
608 605
 		return new CachedEntityIds(
609
-			array_values( array_filter( array_unique( $entityIds ) ) ),
610
-			Metadata::merge( $metadatas )
606
+			array_values(array_filter(array_unique($entityIds))),
607
+			Metadata::merge($metadatas)
611 608
 		);
612 609
 	}
613 610
 
@@ -615,43 +612,43 @@  discard block
 block discarded – undo
615 612
 	 * @throws SparqlHelperException if the query times out or some other error occurs
616 613
 	 * @throws ConstraintParameterException if the $regex is invalid
617 614
 	 */
618
-	public function matchesRegularExpression( string $text, string $regex ): bool {
615
+	public function matchesRegularExpression(string $text, string $regex): bool {
619 616
 		// caching wrapper around matchesRegularExpressionWithSparql
620 617
 
621
-		$textHash = hash( 'sha256', $text );
618
+		$textHash = hash('sha256', $text);
622 619
 		$cacheKey = $this->cache->makeKey(
623 620
 			'WikibaseQualityConstraints', // extension
624 621
 			'regex', // action
625 622
 			'WDQS-Java', // regex flavor
626
-			hash( 'sha256', $regex )
623
+			hash('sha256', $regex)
627 624
 		);
628 625
 
629 626
 		$cacheMapArray = $this->cache->getWithSetCallback(
630 627
 			$cacheKey,
631 628
 			WANObjectCache::TTL_DAY,
632
-			function ( $cacheMapArray ) use ( $text, $regex, $textHash ) {
629
+			function($cacheMapArray) use ($text, $regex, $textHash) {
633 630
 				// Initialize the cache map if not set
634
-				if ( $cacheMapArray === false ) {
631
+				if ($cacheMapArray === false) {
635 632
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.init';
636
-					$this->dataFactory->increment( $key );
633
+					$this->dataFactory->increment($key);
637 634
 					return [];
638 635
 				}
639 636
 
640 637
 				$key = 'wikibase.quality.constraints.regex.cache.refresh';
641
-				$this->dataFactory->increment( $key );
642
-				$cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $this->cacheMapSize );
643
-				if ( $cacheMap->has( $textHash ) ) {
638
+				$this->dataFactory->increment($key);
639
+				$cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $this->cacheMapSize);
640
+				if ($cacheMap->has($textHash)) {
644 641
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.hit';
645
-					$this->dataFactory->increment( $key );
646
-					$cacheMap->get( $textHash ); // ping cache
642
+					$this->dataFactory->increment($key);
643
+					$cacheMap->get($textHash); // ping cache
647 644
 				} else {
648 645
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.miss';
649
-					$this->dataFactory->increment( $key );
646
+					$this->dataFactory->increment($key);
650 647
 					try {
651
-						$matches = $this->matchesRegularExpressionWithSparql( $text, $regex );
652
-					} catch ( ConstraintParameterException $e ) {
653
-						$matches = $this->serializeConstraintParameterException( $e );
654
-					} catch ( SparqlHelperException $e ) {
648
+						$matches = $this->matchesRegularExpressionWithSparql($text, $regex);
649
+					} catch (ConstraintParameterException $e) {
650
+						$matches = $this->serializeConstraintParameterException($e);
651
+					} catch (SparqlHelperException $e) {
655 652
 						// don’t cache this
656 653
 						return $cacheMap->toArray();
657 654
 					}
@@ -675,42 +672,42 @@  discard block
 block discarded – undo
675 672
 			]
676 673
 		);
677 674
 
678
-		if ( isset( $cacheMapArray[$textHash] ) ) {
675
+		if (isset($cacheMapArray[$textHash])) {
679 676
 			$key = 'wikibase.quality.constraints.regex.cache.hit';
680
-			$this->dataFactory->increment( $key );
677
+			$this->dataFactory->increment($key);
681 678
 			$matches = $cacheMapArray[$textHash];
682
-			if ( is_bool( $matches ) ) {
679
+			if (is_bool($matches)) {
683 680
 				return $matches;
684
-			} elseif ( is_array( $matches ) &&
685
-				$matches['type'] == ConstraintParameterException::class ) {
686
-				throw $this->deserializeConstraintParameterException( $matches );
681
+			} elseif (is_array($matches) &&
682
+				$matches['type'] == ConstraintParameterException::class) {
683
+				throw $this->deserializeConstraintParameterException($matches);
687 684
 			} else {
688 685
 				throw new UnexpectedValueException(
689
-					'Value of unknown type in object cache (' .
690
-					'cache key: ' . $cacheKey . ', ' .
691
-					'cache map key: ' . $textHash . ', ' .
692
-					'value type: ' . get_debug_type( $matches ) . ')'
686
+					'Value of unknown type in object cache ('.
687
+					'cache key: '.$cacheKey.', '.
688
+					'cache map key: '.$textHash.', '.
689
+					'value type: '.get_debug_type($matches).')'
693 690
 				);
694 691
 			}
695 692
 		} else {
696 693
 			$key = 'wikibase.quality.constraints.regex.cache.miss';
697
-			$this->dataFactory->increment( $key );
698
-			return $this->matchesRegularExpressionWithSparql( $text, $regex );
694
+			$this->dataFactory->increment($key);
695
+			return $this->matchesRegularExpressionWithSparql($text, $regex);
699 696
 		}
700 697
 	}
701 698
 
702
-	private function serializeConstraintParameterException( ConstraintParameterException $cpe ): array {
699
+	private function serializeConstraintParameterException(ConstraintParameterException $cpe): array {
703 700
 		return [
704 701
 			'type' => ConstraintParameterException::class,
705
-			'violationMessage' => $this->violationMessageSerializer->serialize( $cpe->getViolationMessage() ),
702
+			'violationMessage' => $this->violationMessageSerializer->serialize($cpe->getViolationMessage()),
706 703
 		];
707 704
 	}
708 705
 
709
-	private function deserializeConstraintParameterException( array $serialization ): ConstraintParameterException {
706
+	private function deserializeConstraintParameterException(array $serialization): ConstraintParameterException {
710 707
 		$message = $this->violationMessageDeserializer->deserialize(
711 708
 			$serialization['violationMessage']
712 709
 		);
713
-		return new ConstraintParameterException( $message );
710
+		return new ConstraintParameterException($message);
714 711
 	}
715 712
 
716 713
 	/**
@@ -720,25 +717,25 @@  discard block
 block discarded – undo
720 717
 	 * @throws SparqlHelperException if the query times out or some other error occurs
721 718
 	 * @throws ConstraintParameterException if the $regex is invalid
722 719
 	 */
723
-	public function matchesRegularExpressionWithSparql( string $text, string $regex ): bool {
724
-		$textStringLiteral = $this->stringLiteral( $text );
725
-		$regexStringLiteral = $this->stringLiteral( '^(?:' . $regex . ')$' );
720
+	public function matchesRegularExpressionWithSparql(string $text, string $regex): bool {
721
+		$textStringLiteral = $this->stringLiteral($text);
722
+		$regexStringLiteral = $this->stringLiteral('^(?:'.$regex.')$');
726 723
 
727 724
 		$query = <<<EOF
728 725
 SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {}
729 726
 EOF;
730 727
 
731
-		$result = $this->runQuery( $query, $this->primaryEndpoint, false );
728
+		$result = $this->runQuery($query, $this->primaryEndpoint, false);
732 729
 
733 730
 		$vars = $result->getArray()['results']['bindings'][0];
734
-		if ( array_key_exists( 'matches', $vars ) ) {
731
+		if (array_key_exists('matches', $vars)) {
735 732
 			// true or false ⇒ regex okay, text matches or not
736 733
 			return $vars['matches']['value'] === 'true';
737 734
 		} else {
738 735
 			// empty result: regex broken
739 736
 			throw new ConstraintParameterException(
740
-				( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) )
741
-					->withInlineCode( $regex, Role::CONSTRAINT_PARAMETER_VALUE )
737
+				(new ViolationMessage('wbqc-violation-message-parameter-regex'))
738
+					->withInlineCode($regex, Role::CONSTRAINT_PARAMETER_VALUE)
742 739
 			);
743 740
 		}
744 741
 	}
@@ -746,14 +743,14 @@  discard block
 block discarded – undo
746 743
 	/**
747 744
 	 * Check whether the text content of an error response indicates a query timeout.
748 745
 	 */
749
-	public function isTimeout( string $responseContent ): bool {
750
-		$timeoutRegex = implode( '|', array_map(
751
-			static function ( $fqn ) {
752
-				return preg_quote( $fqn, '/' );
746
+	public function isTimeout(string $responseContent): bool {
747
+		$timeoutRegex = implode('|', array_map(
748
+			static function($fqn) {
749
+				return preg_quote($fqn, '/');
753 750
 			},
754 751
 			$this->timeoutExceptionClasses
755
-		) );
756
-		return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent );
752
+		));
753
+		return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent);
757 754
 	}
758 755
 
759 756
 	/**
@@ -765,17 +762,17 @@  discard block
 block discarded – undo
765 762
 	 * @return int|boolean the max-age (in seconds)
766 763
 	 * or a plain boolean if no max-age can be determined
767 764
 	 */
768
-	public function getCacheMaxAge( array $responseHeaders ) {
765
+	public function getCacheMaxAge(array $responseHeaders) {
769 766
 		if (
770
-			array_key_exists( 'x-cache-status', $responseHeaders ) &&
771
-			preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] )
767
+			array_key_exists('x-cache-status', $responseHeaders) &&
768
+			preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0])
772 769
 		) {
773 770
 			$maxage = [];
774 771
 			if (
775
-				array_key_exists( 'cache-control', $responseHeaders ) &&
776
-				preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage )
772
+				array_key_exists('cache-control', $responseHeaders) &&
773
+				preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage)
777 774
 			) {
778
-				return intval( $maxage[1] );
775
+				return intval($maxage[1]);
779 776
 			} else {
780 777
 				return true;
781 778
 			}
@@ -796,34 +793,34 @@  discard block
 block discarded – undo
796 793
 	 * or SparlHelper::EMPTY_RETRY_AFTER if there is an empty Retry-After
797 794
 	 * or SparlHelper::INVALID_RETRY_AFTER if there is something wrong with the format
798 795
 	 */
799
-	public function getThrottling( MWHttpRequest $request ) {
800
-		$retryAfterValue = $request->getResponseHeader( 'Retry-After' );
801
-		if ( $retryAfterValue === null ) {
796
+	public function getThrottling(MWHttpRequest $request) {
797
+		$retryAfterValue = $request->getResponseHeader('Retry-After');
798
+		if ($retryAfterValue === null) {
802 799
 			return self::NO_RETRY_AFTER;
803 800
 		}
804 801
 
805
-		$trimmedRetryAfterValue = trim( $retryAfterValue );
806
-		if ( $trimmedRetryAfterValue === '' ) {
802
+		$trimmedRetryAfterValue = trim($retryAfterValue);
803
+		if ($trimmedRetryAfterValue === '') {
807 804
 			return self::EMPTY_RETRY_AFTER;
808 805
 		}
809 806
 
810
-		if ( is_numeric( $trimmedRetryAfterValue ) ) {
811
-			$delaySeconds = (int)$trimmedRetryAfterValue;
812
-			if ( $delaySeconds >= 0 ) {
813
-				return $this->getTimestampInFuture( new DateInterval( 'PT' . $delaySeconds . 'S' ) );
807
+		if (is_numeric($trimmedRetryAfterValue)) {
808
+			$delaySeconds = (int) $trimmedRetryAfterValue;
809
+			if ($delaySeconds >= 0) {
810
+				return $this->getTimestampInFuture(new DateInterval('PT'.$delaySeconds.'S'));
814 811
 			}
815 812
 		} else {
816
-			$return = strtotime( $trimmedRetryAfterValue );
817
-			if ( $return !== false ) {
818
-				return new ConvertibleTimestamp( $return );
813
+			$return = strtotime($trimmedRetryAfterValue);
814
+			if ($return !== false) {
815
+				return new ConvertibleTimestamp($return);
819 816
 			}
820 817
 		}
821 818
 		return self::INVALID_RETRY_AFTER;
822 819
 	}
823 820
 
824
-	private function getTimestampInFuture( DateInterval $delta ): ConvertibleTimestamp {
821
+	private function getTimestampInFuture(DateInterval $delta): ConvertibleTimestamp {
825 822
 		$now = new ConvertibleTimestamp();
826
-		return new ConvertibleTimestamp( $now->timestamp->add( $delta ) );
823
+		return new ConvertibleTimestamp($now->timestamp->add($delta));
827 824
 	}
828 825
 
829 826
 	/**
@@ -838,64 +835,63 @@  discard block
 block discarded – undo
838 835
 	 *
839 836
 	 * @throws SparqlHelperException if the query times out or some other error occurs
840 837
 	 */
841
-	protected function runQuery( string $query, string $endpoint, bool $needsPrefixes = true ): CachedQueryResults {
842
-		if ( $this->throttlingLock->isLocked( self::EXPIRY_LOCK_ID ) ) {
843
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' );
838
+	protected function runQuery(string $query, string $endpoint, bool $needsPrefixes = true): CachedQueryResults {
839
+		if ($this->throttlingLock->isLocked(self::EXPIRY_LOCK_ID)) {
840
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling');
844 841
 			throw new TooManySparqlRequestsException();
845 842
 		}
846 843
 
847
-		if ( $this->sparqlHasWikibaseSupport ) {
844
+		if ($this->sparqlHasWikibaseSupport) {
848 845
 			$needsPrefixes = false;
849 846
 		}
850 847
 
851
-		if ( $needsPrefixes ) {
852
-			$query = $this->prefixes . $query;
848
+		if ($needsPrefixes) {
849
+			$query = $this->prefixes.$query;
853 850
 		}
854
-		$query = "#wbqc\n" . $query;
851
+		$query = "#wbqc\n".$query;
855 852
 
856
-		$url = $endpoint . '?' . http_build_query(
853
+		$url = $endpoint.'?'.http_build_query(
857 854
 			[
858 855
 				'query' => $query,
859 856
 				'format' => 'json',
860 857
 				'maxQueryTimeMillis' => $this->maxQueryTimeMillis,
861 858
 			],
862
-			'', ini_get( 'arg_separator.output' ),
859
+			'', ini_get('arg_separator.output'),
863 860
 			// encode spaces with %20, not +
864 861
 			PHP_QUERY_RFC3986
865 862
 		);
866 863
 
867 864
 		$options = [
868 865
 			'method' => 'GET',
869
-			'timeout' => (int)round( ( $this->maxQueryTimeMillis + 1000 ) / 1000 ),
866
+			'timeout' => (int) round(($this->maxQueryTimeMillis + 1000) / 1000),
870 867
 			'connectTimeout' => 'default',
871 868
 			'userAgent' => $this->defaultUserAgent,
872 869
 		];
873
-		$request = $this->requestFactory->create( $url, $options, __METHOD__ );
874
-		$startTime = microtime( true );
870
+		$request = $this->requestFactory->create($url, $options, __METHOD__);
871
+		$startTime = microtime(true);
875 872
 		$requestStatus = $request->execute();
876
-		$endTime = microtime( true );
873
+		$endTime = microtime(true);
877 874
 		$this->dataFactory->timing(
878 875
 			'wikibase.quality.constraints.sparql.timing',
879
-			( $endTime - $startTime ) * 1000
876
+			($endTime - $startTime) * 1000
880 877
 		);
881 878
 
882
-		$this->guardAgainstTooManyRequestsError( $request );
879
+		$this->guardAgainstTooManyRequestsError($request);
883 880
 
884
-		$maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() );
885
-		if ( $maxAge ) {
886
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.cached' );
881
+		$maxAge = $this->getCacheMaxAge($request->getResponseHeaders());
882
+		if ($maxAge) {
883
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.cached');
887 884
 		}
888 885
 
889
-		if ( $requestStatus->isOK() ) {
886
+		if ($requestStatus->isOK()) {
890 887
 			$json = $request->getContent();
891
-			$jsonStatus = FormatJson::parse( $json, FormatJson::FORCE_ASSOC );
892
-			if ( $jsonStatus->isOK() ) {
888
+			$jsonStatus = FormatJson::parse($json, FormatJson::FORCE_ASSOC);
889
+			if ($jsonStatus->isOK()) {
893 890
 				return new CachedQueryResults(
894 891
 					$jsonStatus->getValue(),
895 892
 					Metadata::ofCachingMetadata(
896 893
 						$maxAge ?
897
-							CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) :
898
-							CachingMetadata::fresh()
894
+							CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh()
899 895
 					)
900 896
 				);
901 897
 			} else {
@@ -912,9 +908,9 @@  discard block
 block discarded – undo
912 908
 			// fall through to general error handling
913 909
 		}
914 910
 
915
-		$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.error' );
911
+		$this->dataFactory->increment('wikibase.quality.constraints.sparql.error');
916 912
 
917
-		if ( $this->isTimeout( $request->getContent() ) ) {
913
+		if ($this->isTimeout($request->getContent())) {
918 914
 			$this->dataFactory->increment(
919 915
 				'wikibase.quality.constraints.sparql.error.timeout'
920 916
 			);
@@ -929,29 +925,29 @@  discard block
 block discarded – undo
929 925
 	 * @param MWHttpRequest $request
930 926
 	 * @throws TooManySparqlRequestsException
931 927
 	 */
932
-	private function guardAgainstTooManyRequestsError( MWHttpRequest $request ): void {
933
-		if ( $request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS ) {
928
+	private function guardAgainstTooManyRequestsError(MWHttpRequest $request): void {
929
+		if ($request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS) {
934 930
 			return;
935 931
 		}
936 932
 
937 933
 		$fallbackBlockDuration = $this->sparqlThrottlingFallbackDuration;
938 934
 
939
-		if ( $fallbackBlockDuration < 0 ) {
940
-			throw new InvalidArgumentException( 'Fallback duration must be positive int but is: ' .
941
-				$fallbackBlockDuration );
935
+		if ($fallbackBlockDuration < 0) {
936
+			throw new InvalidArgumentException('Fallback duration must be positive int but is: '.
937
+				$fallbackBlockDuration);
942 938
 		}
943 939
 
944
-		$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' );
945
-		$throttlingUntil = $this->getThrottling( $request );
946
-		if ( !( $throttlingUntil instanceof ConvertibleTimestamp ) ) {
947
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid( $request );
940
+		$this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling');
941
+		$throttlingUntil = $this->getThrottling($request);
942
+		if (!($throttlingUntil instanceof ConvertibleTimestamp)) {
943
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid($request);
948 944
 			$this->throttlingLock->lock(
949 945
 				self::EXPIRY_LOCK_ID,
950
-				$this->getTimestampInFuture( new DateInterval( 'PT' . $fallbackBlockDuration . 'S' ) )
946
+				$this->getTimestampInFuture(new DateInterval('PT'.$fallbackBlockDuration.'S'))
951 947
 			);
952 948
 		} else {
953
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent( $throttlingUntil, $request );
954
-			$this->throttlingLock->lock( self::EXPIRY_LOCK_ID, $throttlingUntil );
949
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent($throttlingUntil, $request);
950
+			$this->throttlingLock->lock(self::EXPIRY_LOCK_ID, $throttlingUntil);
955 951
 		}
956 952
 		throw new TooManySparqlRequestsException();
957 953
 	}
Please login to merge, or discard this patch.