Completed
Push — master ( a39e01...651fc0 )
by
unknown
21s
created
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 		$this->statsFactory = $statsFactory;
54 54
 		$this->logger = $logger;
55 55
 		$this->constraintCheckDurationLimits = [
56
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
57
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
56
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
57
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
58 58
 		];
59 59
 		$this->constraintCheckOnEntityDurationLimits = [
60
-			'info' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationInfoSeconds' ),
61
-			'warning' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationWarningSeconds' ),
60
+			'info' => $config->get('WBQualityConstraintsCheckOnEntityDurationInfoSeconds'),
61
+			'warning' => $config->get('WBQualityConstraintsCheckOnEntityDurationWarningSeconds'),
62 62
 		];
63 63
 	}
64 64
 
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	 * @param float $durationSeconds
71 71
 	 * @return array [ $limitSeconds, $logLevel ]
72 72
 	 */
73
-	private function findLimit( $limits, $durationSeconds ) {
73
+	private function findLimit($limits, $durationSeconds) {
74 74
 		$limitSeconds = null;
75 75
 		$logLevel = null;
76 76
 
77
-		foreach ( $limits as $level => $limit ) {
77
+		foreach ($limits as $level => $limit) {
78 78
 			if (
79 79
 				// duration exceeds this limit
80 80
 				$limit !== null && $durationSeconds > $limit &&
81 81
 				// this limit is longer than previous longest limit
82
-				( $limitSeconds === null || $limit > $limitSeconds )
82
+				($limitSeconds === null || $limit > $limitSeconds)
83 83
 			) {
84 84
 				$limitSeconds = $limit;
85 85
 				$logLevel = $level;
86 86
 			}
87 87
 		}
88 88
 
89
-		return [ $limitSeconds, $logLevel ];
89
+		return [$limitSeconds, $logLevel];
90 90
 	}
91 91
 
92 92
 	/**
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 		$durationSeconds,
112 112
 		$method
113 113
 	) {
114
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
114
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
115 115
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
116 116
 
117 117
 		$baseCheckTimingKey = 'wikibase.quality.constraints.check.timing';
118 118
 		$this->statsFactory
119
-			->getTiming( 'check_constraint_duration_seconds' )
120
-			->copyToStatsdAt( "$baseCheckTimingKey.$constraintTypeItemId-$constraintCheckerClassShortName" )
121
-			->observe( $durationSeconds * 1000 );
119
+			->getTiming('check_constraint_duration_seconds')
120
+			->copyToStatsdAt("$baseCheckTimingKey.$constraintTypeItemId-$constraintCheckerClassShortName")
121
+			->observe($durationSeconds * 1000);
122 122
 
123 123
 		// find the longest limit (and associated log level) that the duration exceeds
124
-		[ $limitSeconds, $logLevel ] = $this->findLimit(
124
+		[$limitSeconds, $logLevel] = $this->findLimit(
125 125
 			$this->constraintCheckDurationLimits,
126 126
 			$durationSeconds
127 127
 		);
128
-		if ( $limitSeconds === null ) {
128
+		if ($limitSeconds === null) {
129 129
 			return;
130 130
 		}
131
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
131
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
132 132
 			// TODO log less details but still log something
133 133
 			return;
134 134
 		}
135 135
 
136 136
 		$resultMessage = $result->getMessage();
137
-		if ( $resultMessage !== null ) {
137
+		if ($resultMessage !== null) {
138 138
 			$resultMessageKey = $resultMessage->getMessageKey();
139 139
 		} else {
140 140
 			$resultMessageKey = null;
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 
143 143
 		$this->logger->log(
144 144
 			$logLevel,
145
-			'Constraint check with {constraintCheckerClassShortName} ' .
146
-			'took longer than {limitSeconds} second(s) ' .
145
+			'Constraint check with {constraintCheckerClassShortName} '.
146
+			'took longer than {limitSeconds} second(s) '.
147 147
 			'(duration: {durationSeconds} seconds).',
148 148
 			[
149 149
 				'method' => $method,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				'constraintId' => $constraint->getConstraintId(),
154 154
 				'constraintPropertyId' => $constraint->getPropertyId()->getSerialization(),
155 155
 				'constraintTypeItemId' => $constraintTypeItemId,
156
-				'constraintParameters' => json_encode( $constraint->getConstraintParameters() ),
156
+				'constraintParameters' => json_encode($constraint->getConstraintParameters()),
157 157
 				'constraintCheckerClass' => $constraintCheckerClass,
158 158
 				'constraintCheckerClassShortName' => $constraintCheckerClassShortName,
159 159
 				'entityId' => $context->getEntity()->getId()->getSerialization(),
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 	) {
186 186
 		$checkEntityTimingKey = 'wikibase.quality.constraints.check.entity.timing';
187 187
 		$this->statsFactory
188
-			->getTiming( 'check_entity_constraint_duration_seconds' )
189
-			->copyToStatsdAt( $checkEntityTimingKey )
190
-			->observe( $durationSeconds * 1000 );
188
+			->getTiming('check_entity_constraint_duration_seconds')
189
+			->copyToStatsdAt($checkEntityTimingKey)
190
+			->observe($durationSeconds * 1000);
191 191
 
192 192
 		// find the longest limit (and associated log level) that the duration exceeds
193
-		[ $limitSeconds, $logLevel ] = $this->findLimit(
193
+		[$limitSeconds, $logLevel] = $this->findLimit(
194 194
 			$this->constraintCheckOnEntityDurationLimits,
195 195
 			$durationSeconds
196 196
 		);
197
-		if ( $limitSeconds === null ) {
197
+		if ($limitSeconds === null) {
198 198
 			return;
199 199
 		}
200 200
 
201 201
 		$this->logger->log(
202 202
 			$logLevel,
203
-			'Full constraint check on {entityId} ' .
204
-			'took longer than {limitSeconds} second(s) ' .
203
+			'Full constraint check on {entityId} '.
204
+			'took longer than {limitSeconds} second(s) '.
205 205
 			'(duration: {durationSeconds} seconds).',
206 206
 			[
207 207
 				'method' => $method,
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	/**
218 218
 	 * Log a cache hit for a complete constraint check result for the given entity ID.
219 219
 	 */
220
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
220
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
221 221
 		$cacheEntityHitKey = 'wikibase.quality.constraints.cache.entity.hit';
222
-		$metric = $this->statsFactory->getCounter( 'cache_entity_hit_total' );
222
+		$metric = $this->statsFactory->getCounter('cache_entity_hit_total');
223 223
 		$metric->copyToStatsdAt(
224 224
 				$cacheEntityHitKey,
225 225
 			)->increment();
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @param EntityId[] $entityIds
232 232
 	 */
233
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
233
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
234 234
 		$cacheEntityMissKey = 'wikibase.quality.constraints.cache.entity.miss';
235
-		$metric = $this->statsFactory->getCounter( 'cache_entity_miss_total' );
235
+		$metric = $this->statsFactory->getCounter('cache_entity_miss_total');
236 236
 		$metric->copyToStatsdAt(
237 237
 				$cacheEntityMissKey,
238
-			)->incrementBy( count( $entityIds ) );
238
+			)->incrementBy(count($entityIds));
239 239
 	}
240 240
 
241 241
 	/**
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 	 * @param EntityId[] $entityIds
262 262
 	 * @param int $maxRevisionIds
263 263
 	 */
264
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
264
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
265 265
 		$this->logger->log(
266 266
 			'warning',
267
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
268
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
267
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
268
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
269 269
 			'caching disabled for this check result.',
270 270
 			[
271 271
 				'loggingMethod' => __METHOD__,
272 272
 				'entityIds' => json_encode(
273 273
 					array_map(
274
-						static function ( EntityId $entityId ) {
274
+						static function(EntityId $entityId) {
275 275
 							return $entityId->getSerialization();
276 276
 						},
277 277
 						$entityIds
@@ -290,17 +290,17 @@  discard block
 block discarded – undo
290 290
 			'Sparql API replied with status 429 and a retry-after header. Requesting to retry after {retryAfterTime}',
291 291
 			[
292 292
 				'retryAfterTime' => $retryAfterTime,
293
-				'responseHeaders' => json_encode( $request->getResponseHeaders() ),
293
+				'responseHeaders' => json_encode($request->getResponseHeaders()),
294 294
 				'responseContent' => $request->getContent(),
295 295
 			]
296 296
 		);
297 297
 	}
298 298
 
299
-	public function logSparqlHelperTooManyRequestsRetryAfterInvalid( MWHttpRequest $request ) {
299
+	public function logSparqlHelperTooManyRequestsRetryAfterInvalid(MWHttpRequest $request) {
300 300
 		$this->logger->warning(
301 301
 			'Sparql API replied with status 429 and no valid retry-after header.',
302 302
 			[
303
-				'responseHeaders' => json_encode( $request->getResponseHeaders() ),
303
+				'responseHeaders' => json_encode($request->getResponseHeaders()),
304 304
 				'responseContent' => $request->getContent(),
305 305
 			]
306 306
 		);
Please login to merge, or discard this patch.
src/Api/CachingResultsSource.php 1 patch
Spacing   +77 added lines, -78 removed lines patch added patch discarded remove patch
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	) {
145 145
 		$results = [];
146 146
 		$metadatas = [];
147
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
147
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
148 148
 			$storedEntityIds = [];
149
-			foreach ( $entityIds as $entityId ) {
150
-				$storedResults = $this->getStoredResults( $entityId );
151
-				if ( $storedResults !== null ) {
152
-					$this->loggingHelper->logCheckConstraintsCacheHit( $entityId );
153
-					foreach ( $storedResults->getArray() as $checkResult ) {
154
-						if ( $this->statusSelected( $statuses, $checkResult ) ) {
149
+			foreach ($entityIds as $entityId) {
150
+				$storedResults = $this->getStoredResults($entityId);
151
+				if ($storedResults !== null) {
152
+					$this->loggingHelper->logCheckConstraintsCacheHit($entityId);
153
+					foreach ($storedResults->getArray() as $checkResult) {
154
+						if ($this->statusSelected($statuses, $checkResult)) {
155 155
 							$results[] = $checkResult;
156 156
 						}
157 157
 					}
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
 					$storedEntityIds[] = $entityId;
160 160
 				}
161 161
 			}
162
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
162
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
163 163
 		}
164
-		if ( $entityIds !== [] || $claimIds !== [] ) {
165
-			if ( $entityIds !== [] ) {
166
-				$this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds );
164
+		if ($entityIds !== [] || $claimIds !== []) {
165
+			if ($entityIds !== []) {
166
+				$this->loggingHelper->logCheckConstraintsCacheMisses($entityIds);
167 167
 			}
168
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
169
-			$results = array_merge( $results, $response->getArray() );
168
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
169
+			$results = array_merge($results, $response->getArray());
170 170
 			$metadatas[] = $response->getMetadata();
171 171
 		}
172 172
 		return new CachedCheckResults(
173 173
 			$results,
174
-			Metadata::merge( $metadatas )
174
+			Metadata::merge($metadatas)
175 175
 		);
176 176
 	}
177 177
 
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
 		?array $constraintIds,
195 195
 		array $statuses
196 196
 	) {
197
-		if ( $claimIds !== [] ) {
197
+		if ($claimIds !== []) {
198 198
 			return false;
199 199
 		}
200
-		if ( $constraintIds !== null ) {
200
+		if ($constraintIds !== null) {
201 201
 			return false;
202 202
 		}
203
-		if ( array_diff( $statuses, self::CACHED_STATUSES ) !== [] ) {
203
+		if (array_diff($statuses, self::CACHED_STATUSES) !== []) {
204 204
 			return false;
205 205
 		}
206 206
 		return true;
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param CheckResult $result
216 216
 	 * @return bool
217 217
 	 */
218
-	private function statusSelected( array $statuses, CheckResult $result ) {
219
-		return in_array( $result->getStatus(), $statuses, true ) ||
218
+	private function statusSelected(array $statuses, CheckResult $result) {
219
+		return in_array($result->getStatus(), $statuses, true) ||
220 220
 			$result instanceof NullResult;
221 221
 	}
222 222
 
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 		?array $constraintIds,
234 234
 		array $statuses
235 235
 	) {
236
-		$results = $this->resultsSource->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
236
+		$results = $this->resultsSource->getResults($entityIds, $claimIds, $constraintIds, $statuses);
237 237
 
238
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
239
-			foreach ( $entityIds as $entityId ) {
240
-				$this->storeResults( $entityId, $results );
238
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
239
+			foreach ($entityIds as $entityId) {
240
+				$this->storeResults($entityId, $results);
241 241
 			}
242 242
 		}
243 243
 
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 		?array $constraintIds,
269 269
 		array $statuses
270 270
 	) {
271
-		if ( $constraintIds !== null ) {
271
+		if ($constraintIds !== null) {
272 272
 			return false;
273 273
 		}
274
-		if ( array_diff( self::CACHED_STATUSES, $statuses ) !== [] ) {
274
+		if (array_diff(self::CACHED_STATUSES, $statuses) !== []) {
275 275
 			return false;
276 276
 		}
277 277
 		return true;
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
 	 * May include check results for other entity IDs as well,
286 286
 	 * or check results with statuses that we’re not interested in caching.
287 287
 	 */
288
-	private function storeResults( EntityId $entityId, CachedCheckResults $results ) {
288
+	private function storeResults(EntityId $entityId, CachedCheckResults $results) {
289 289
 		$latestRevisionIds = $this->getLatestRevisionIds(
290 290
 			$results->getMetadata()->getDependencyMetadata()->getEntityIds()
291 291
 		);
292
-		if ( $latestRevisionIds === null ) {
292
+		if ($latestRevisionIds === null) {
293 293
 			return;
294 294
 		}
295 295
 
296 296
 		$resultSerializations = [];
297
-		foreach ( $results->getArray() as $checkResult ) {
298
-			if ( $checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization() ) {
297
+		foreach ($results->getArray() as $checkResult) {
298
+			if ($checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization()) {
299 299
 				continue;
300 300
 			}
301
-			if ( $this->statusSelected( self::CACHED_STATUSES, $checkResult ) ) {
302
-				$resultSerializations[] = $this->checkResultSerializer->serialize( $checkResult );
301
+			if ($this->statusSelected(self::CACHED_STATUSES, $checkResult)) {
302
+				$resultSerializations[] = $this->checkResultSerializer->serialize($checkResult);
303 303
 			}
304 304
 		}
305 305
 
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 			'latestRevisionIds' => $latestRevisionIds,
309 309
 		];
310 310
 		$futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime();
311
-		if ( $futureTime !== null ) {
311
+		if ($futureTime !== null) {
312 312
 			$value['futureTime'] = $futureTime->getArrayValue();
313 313
 		}
314 314
 
315
-		$this->cache->set( $entityId, $value, $this->ttlInSeconds );
315
+		$this->cache->set($entityId, $value, $this->ttlInSeconds);
316 316
 	}
317 317
 
318 318
 	/**
@@ -327,33 +327,32 @@  discard block
 block discarded – undo
327 327
 		$forRevision = 0
328 328
 	) {
329 329
 		$cacheInfo = WANObjectCache::PASS_BY_REF;
330
-		$value = $this->cache->get( $entityId, $curTTL, [], $cacheInfo );
331
-		$now = ( $this->microtime )( true );
330
+		$value = $this->cache->get($entityId, $curTTL, [], $cacheInfo);
331
+		$now = ($this->microtime)(true);
332 332
 
333
-		$dependencyMetadata = $this->checkDependencyMetadata( $value,
334
-			[ $entityId->getSerialization() => $forRevision ] );
335
-		if ( $dependencyMetadata === null ) {
333
+		$dependencyMetadata = $this->checkDependencyMetadata($value,
334
+			[$entityId->getSerialization() => $forRevision]);
335
+		if ($dependencyMetadata === null) {
336 336
 			return null;
337 337
 		}
338 338
 
339 339
 		// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset False positive
340 340
 		$asOf = $cacheInfo[WANObjectCache::KEY_AS_OF];
341
-		$ageInSeconds = (int)ceil( $now - $asOf );
341
+		$ageInSeconds = (int) ceil($now - $asOf);
342 342
 		$cachingMetadata = $ageInSeconds > 0 ?
343
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
344
-			CachingMetadata::fresh();
343
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
345 344
 
346 345
 		$results = [];
347
-		foreach ( $value['results'] as $resultSerialization ) {
348
-			$results[] = $this->deserializeCheckResult( $resultSerialization, $cachingMetadata );
346
+		foreach ($value['results'] as $resultSerialization) {
347
+			$results[] = $this->deserializeCheckResult($resultSerialization, $cachingMetadata);
349 348
 		}
350 349
 
351 350
 		return new CachedCheckResults(
352 351
 			$results,
353
-			Metadata::merge( [
354
-				Metadata::ofCachingMetadata( $cachingMetadata ),
355
-				Metadata::ofDependencyMetadata( $dependencyMetadata ),
356
-			] )
352
+			Metadata::merge([
353
+				Metadata::ofCachingMetadata($cachingMetadata),
354
+				Metadata::ofDependencyMetadata($dependencyMetadata),
355
+			])
357 356
 		);
358 357
 	}
359 358
 
@@ -369,43 +368,43 @@  discard block
 block discarded – undo
369 368
 	 * @return DependencyMetadata|null the dependency metadata,
370 369
 	 * or null if $value should no longer be used
371 370
 	 */
372
-	private function checkDependencyMetadata( $value, $paramRevs ) {
373
-		if ( $value === false ) {
371
+	private function checkDependencyMetadata($value, $paramRevs) {
372
+		if ($value === false) {
374 373
 			return null;
375 374
 		}
376 375
 
377
-		if ( array_key_exists( 'futureTime', $value ) ) {
378
-			$futureTime = TimeValue::newFromArray( $value['futureTime'] );
379
-			if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) {
376
+		if (array_key_exists('futureTime', $value)) {
377
+			$futureTime = TimeValue::newFromArray($value['futureTime']);
378
+			if (!$this->timeValueComparer->isFutureTime($futureTime)) {
380 379
 				return null;
381 380
 			}
382
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
381
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
383 382
 		} else {
384 383
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
385 384
 		}
386 385
 
387
-		foreach ( $paramRevs as $id => $revision ) {
388
-			if ( $revision > 0 ) {
389
-				$value['latestRevisionIds'][$id] = min( $revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX );
386
+		foreach ($paramRevs as $id => $revision) {
387
+			if ($revision > 0) {
388
+				$value['latestRevisionIds'][$id] = min($revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX);
390 389
 			}
391 390
 		}
392 391
 
393 392
 		$dependedEntityIds = array_map(
394
-			[ $this->entityIdParser, "parse" ],
395
-			array_keys( $value['latestRevisionIds'] )
393
+			[$this->entityIdParser, "parse"],
394
+			array_keys($value['latestRevisionIds'])
396 395
 		);
397 396
 
398
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
397
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
399 398
 			return null;
400 399
 		}
401 400
 
402 401
 		return array_reduce(
403 402
 			$dependedEntityIds,
404
-			static function ( DependencyMetadata $metadata, EntityId $entityId ) {
405
-				return DependencyMetadata::merge( [
403
+			static function(DependencyMetadata $metadata, EntityId $entityId) {
404
+				return DependencyMetadata::merge([
406 405
 					$metadata,
407
-					DependencyMetadata::ofEntityId( $entityId ),
408
-				] );
406
+					DependencyMetadata::ofEntityId($entityId),
407
+				]);
409 408
 			},
410 409
 			$futureTimeDependencyMetadata
411 410
 		);
@@ -425,13 +424,13 @@  discard block
 block discarded – undo
425 424
 		array $resultSerialization,
426 425
 		CachingMetadata $cachingMetadata
427 426
 	) {
428
-		$result = $this->checkResultDeserializer->deserialize( $resultSerialization );
429
-		if ( $this->isPossiblyStaleResult( $result ) ) {
427
+		$result = $this->checkResultDeserializer->deserialize($resultSerialization);
428
+		if ($this->isPossiblyStaleResult($result)) {
430 429
 			$result->withMetadata(
431
-				Metadata::merge( [
430
+				Metadata::merge([
432 431
 					$result->getMetadata(),
433
-					Metadata::ofCachingMetadata( $cachingMetadata ),
434
-				] )
432
+					Metadata::ofCachingMetadata($cachingMetadata),
433
+				])
435 434
 			);
436 435
 		}
437 436
 		return $result;
@@ -441,8 +440,8 @@  discard block
 block discarded – undo
441 440
 	 * @param CheckResult $result
442 441
 	 * @return bool
443 442
 	 */
444
-	private function isPossiblyStaleResult( CheckResult $result ) {
445
-		if ( $result instanceof NullResult ) {
443
+	private function isPossiblyStaleResult(CheckResult $result) {
444
+		if ($result instanceof NullResult) {
446 445
 			return false;
447 446
 		}
448 447
 
@@ -457,14 +456,14 @@  discard block
 block discarded – undo
457 456
 	 * @return int[]|null array from entity ID serializations to revision ID,
458 457
 	 * or null to indicate that not all revision IDs could be loaded
459 458
 	 */
460
-	private function getLatestRevisionIds( array $entityIds ) {
461
-		if ( $entityIds === [] ) {
459
+	private function getLatestRevisionIds(array $entityIds) {
460
+		if ($entityIds === []) {
462 461
 			$this->loggingHelper->logEmptyDependencyMetadata();
463 462
 			return [];
464 463
 		}
465
-		if ( count( $entityIds ) > $this->maxRevisionIds ) {
464
+		if (count($entityIds) > $this->maxRevisionIds) {
466 465
 			// one of those entities will probably be edited soon, so might as well skip caching
467
-			$this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds );
466
+			$this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds);
468 467
 			return null;
469 468
 		}
470 469
 
@@ -472,7 +471,7 @@  discard block
 block discarded – undo
472 471
 			$entityIds,
473 472
 			LookupConstants::LATEST_FROM_REPLICA
474 473
 		);
475
-		if ( $this->hasFalseElements( $latestRevisionIds ) ) {
474
+		if ($this->hasFalseElements($latestRevisionIds)) {
476 475
 			return null;
477 476
 		}
478 477
 		return $latestRevisionIds;
@@ -482,14 +481,14 @@  discard block
 block discarded – undo
482 481
 	 * @param array $array
483 482
 	 * @return bool
484 483
 	 */
485
-	private function hasFalseElements( array $array ) {
486
-		return in_array( false, $array, true );
484
+	private function hasFalseElements(array $array) {
485
+		return in_array(false, $array, true);
487 486
 	}
488 487
 
489 488
 	/**
490 489
 	 * Set a custom function to get the current time, instead of microtime().
491 490
 	 */
492
-	public function setMicrotimeFunction( callable $microtime ) {
491
+	public function setMicrotimeFunction(callable $microtime) {
493 492
 		$this->microtime = $microtime;
494 493
 	}
495 494
 
Please login to merge, or discard this patch.