@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | $this->dataFactory = $dataFactory; |
| 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 | |
@@ -69,23 +69,23 @@ discard block |
||
| 69 | 69 | * @param float $durationSeconds |
| 70 | 70 | * @return array [ $limitSeconds, $logLevel ] |
| 71 | 71 | */ |
| 72 | - private function findLimit( $limits, $durationSeconds ) { |
|
| 72 | + private function findLimit($limits, $durationSeconds) { |
|
| 73 | 73 | $limitSeconds = null; |
| 74 | 74 | $logLevel = null; |
| 75 | 75 | |
| 76 | - foreach ( $limits as $level => $limit ) { |
|
| 76 | + foreach ($limits as $level => $limit) { |
|
| 77 | 77 | if ( |
| 78 | 78 | // duration exceeds this limit |
| 79 | 79 | $limit !== null && $durationSeconds > $limit && |
| 80 | 80 | // this limit is longer than previous longest limit |
| 81 | - ( $limitSeconds === null || $limit > $limitSeconds ) |
|
| 81 | + ($limitSeconds === null || $limit > $limitSeconds) |
|
| 82 | 82 | ) { |
| 83 | 83 | $limitSeconds = $limit; |
| 84 | 84 | $logLevel = $level; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return [ $limitSeconds, $logLevel ]; |
|
| 88 | + return [$limitSeconds, $logLevel]; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -110,31 +110,31 @@ discard block |
||
| 110 | 110 | $durationSeconds, |
| 111 | 111 | $method |
| 112 | 112 | ) { |
| 113 | - $constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 ); |
|
| 113 | + $constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1); |
|
| 114 | 114 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
| 115 | 115 | |
| 116 | 116 | $this->dataFactory->timing( |
| 117 | - 'wikibase.quality.constraints.check.timing.' . |
|
| 118 | - $constraintTypeItemId . '-' . |
|
| 117 | + 'wikibase.quality.constraints.check.timing.'. |
|
| 118 | + $constraintTypeItemId.'-'. |
|
| 119 | 119 | $constraintCheckerClassShortName, |
| 120 | 120 | $durationSeconds * 1000 |
| 121 | 121 | ); |
| 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 |
||
| 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 |
||
| 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(), |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | // find the longest limit (and associated log level) that the duration exceeds |
| 191 | - [ $limitSeconds, $logLevel ] = $this->findLimit( |
|
| 191 | + [$limitSeconds, $logLevel] = $this->findLimit( |
|
| 192 | 192 | $this->constraintCheckOnEntityDurationLimits, |
| 193 | 193 | $durationSeconds |
| 194 | 194 | ); |
| 195 | - if ( $limitSeconds === null ) { |
|
| 195 | + if ($limitSeconds === null) { |
|
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $this->logger->log( |
| 200 | 200 | $logLevel, |
| 201 | - 'Full constraint check on {entityId} ' . |
|
| 202 | - 'took longer than {limitSeconds} second(s) ' . |
|
| 201 | + 'Full constraint check on {entityId} '. |
|
| 202 | + 'took longer than {limitSeconds} second(s) '. |
|
| 203 | 203 | '(duration: {durationSeconds} seconds).', |
| 204 | 204 | [ |
| 205 | 205 | 'method' => $method, |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @param EntityId $entityId |
| 219 | 219 | */ |
| 220 | - public function logCheckConstraintsCacheHit( EntityId $entityId ) { |
|
| 220 | + public function logCheckConstraintsCacheHit(EntityId $entityId) { |
|
| 221 | 221 | $this->dataFactory->increment( |
| 222 | 222 | 'wikibase.quality.constraints.cache.entity.hit' |
| 223 | 223 | ); |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @param EntityId[] $entityIds |
| 230 | 230 | */ |
| 231 | - public function logCheckConstraintsCacheMisses( array $entityIds ) { |
|
| 231 | + public function logCheckConstraintsCacheMisses(array $entityIds) { |
|
| 232 | 232 | $this->dataFactory->updateCount( |
| 233 | 233 | 'wikibase.quality.constraints.cache.entity.miss', |
| 234 | - count( $entityIds ) |
|
| 234 | + count($entityIds) |
|
| 235 | 235 | ); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -258,17 +258,17 @@ discard block |
||
| 258 | 258 | * @param EntityId[] $entityIds |
| 259 | 259 | * @param int $maxRevisionIds |
| 260 | 260 | */ |
| 261 | - public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) { |
|
| 261 | + public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) { |
|
| 262 | 262 | $this->logger->log( |
| 263 | 263 | 'warning', |
| 264 | - 'Dependency metadata for constraint check result has huge set of entity IDs ' . |
|
| 265 | - '(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' . |
|
| 264 | + 'Dependency metadata for constraint check result has huge set of entity IDs '. |
|
| 265 | + '(count '.count($entityIds).', limit '.$maxRevisionIds.'); '. |
|
| 266 | 266 | 'caching disabled for this check result.', |
| 267 | 267 | [ |
| 268 | 268 | 'loggingMethod' => __METHOD__, |
| 269 | 269 | 'entityIds' => json_encode( |
| 270 | 270 | array_map( |
| 271 | - static function ( EntityId $entityId ) { |
|
| 271 | + static function(EntityId $entityId) { |
|
| 272 | 272 | return $entityId->getSerialization(); |
| 273 | 273 | }, |
| 274 | 274 | $entityIds |
@@ -287,17 +287,17 @@ discard block |
||
| 287 | 287 | 'Sparql API replied with status 429 and a retry-after header. Requesting to retry after {retryAfterTime}', |
| 288 | 288 | [ |
| 289 | 289 | 'retryAfterTime' => $retryAfterTime, |
| 290 | - 'responseHeaders' => json_encode( $request->getResponseHeaders() ), |
|
| 290 | + 'responseHeaders' => json_encode($request->getResponseHeaders()), |
|
| 291 | 291 | 'responseContent' => $request->getContent(), |
| 292 | 292 | ] |
| 293 | 293 | ); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - public function logSparqlHelperTooManyRequestsRetryAfterInvalid( MWHttpRequest $request ) { |
|
| 296 | + public function logSparqlHelperTooManyRequestsRetryAfterInvalid(MWHttpRequest $request) { |
|
| 297 | 297 | $this->logger->warning( |
| 298 | 298 | 'Sparql API replied with status 429 and no valid retry-after header.', |
| 299 | 299 | [ |
| 300 | - 'responseHeaders' => json_encode( $request->getResponseHeaders() ), |
|
| 300 | + 'responseHeaders' => json_encode($request->getResponseHeaders()), |
|
| 301 | 301 | 'responseContent' => $request->getContent(), |
| 302 | 302 | ] |
| 303 | 303 | ); |