@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | private const BATCH_SIZE = 50; |
40 | 40 | |
41 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
42 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
41 | + public static function newFromGlobalState(Title $title, array $params) { |
|
42 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
43 | 43 | $services = MediaWikiServices::getInstance(); |
44 | 44 | $repo = WikibaseRepo::getDefaultInstance(); |
45 | 45 | return new UpdateConstraintsTableJob( |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $services->getMainConfig(), |
51 | 51 | ConstraintsServices::getConstraintStore(), |
52 | 52 | $services->getDBLoadBalancerFactory(), |
53 | - $repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
53 | + $repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
54 | 54 | $repo->getBaseDataModelSerializerFactory()->newSnakSerializer() |
55 | 55 | ); |
56 | 56 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | EntityRevisionLookup $entityRevisionLookup, |
111 | 111 | Serializer $snakSerializer |
112 | 112 | ) { |
113 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
113 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
114 | 114 | |
115 | 115 | $this->propertyId = $propertyId; |
116 | 116 | $this->revisionId = $revisionId; |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | $this->snakSerializer = $snakSerializer; |
122 | 122 | } |
123 | 123 | |
124 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
124 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
125 | 125 | $parameters = []; |
126 | - foreach ( $qualifiers as $qualifier ) { |
|
126 | + foreach ($qualifiers as $qualifier) { |
|
127 | 127 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
128 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
128 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
129 | 129 | $parameters[$qualifierId][] = $paramSerialization; |
130 | 130 | } |
131 | 131 | return $parameters; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | '@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue'; |
143 | 143 | $entityId = $dataValue->getEntityId(); |
144 | 144 | $constraintTypeQid = $entityId->getSerialization(); |
145 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
145 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
146 | 146 | return new Constraint( |
147 | 147 | $constraintId, |
148 | 148 | $propertyId, |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | PropertyId $propertyConstraintPropertyId |
158 | 158 | ) { |
159 | 159 | $constraintsStatements = $property->getStatements() |
160 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
161 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
160 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
161 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
162 | 162 | $constraints = []; |
163 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
164 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
165 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
166 | - $constraintStore->insertBatch( $constraints ); |
|
163 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
164 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
165 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
166 | + $constraintStore->insertBatch($constraints); |
|
167 | 167 | // interrupt transaction and wait for replication |
168 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
169 | - $connection->endAtomic( __CLASS__ ); |
|
170 | - if ( !$connection->explicitTrxActive() ) { |
|
168 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
169 | + $connection->endAtomic(__CLASS__); |
|
170 | + if (!$connection->explicitTrxActive()) { |
|
171 | 171 | $this->lbFactory->waitForReplication(); |
172 | 172 | } |
173 | - $connection->startAtomic( __CLASS__ ); |
|
173 | + $connection->startAtomic(__CLASS__); |
|
174 | 174 | $constraints = []; |
175 | 175 | } |
176 | 176 | } |
177 | - $constraintStore->insertBatch( $constraints ); |
|
177 | + $constraintStore->insertBatch($constraints); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -185,24 +185,24 @@ discard block |
||
185 | 185 | public function run() { |
186 | 186 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
187 | 187 | |
188 | - $propertyId = new PropertyId( $this->propertyId ); |
|
188 | + $propertyId = new PropertyId($this->propertyId); |
|
189 | 189 | $propertyRevision = $this->entityRevisionLookup->getEntityRevision( |
190 | 190 | $propertyId, |
191 | 191 | 0, // latest |
192 | 192 | LookupConstants::LATEST_FROM_REPLICA |
193 | 193 | ); |
194 | 194 | |
195 | - if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) { |
|
196 | - JobQueueGroup::singleton()->push( $this ); |
|
195 | + if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) { |
|
196 | + JobQueueGroup::singleton()->push($this); |
|
197 | 197 | return true; |
198 | 198 | } |
199 | 199 | |
200 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
200 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
201 | 201 | // start transaction (if not started yet) – using __CLASS__, not __METHOD__, |
202 | 202 | // because importConstraintsForProperty() can interrupt the transaction |
203 | - $connection->startAtomic( __CLASS__ ); |
|
203 | + $connection->startAtomic(__CLASS__); |
|
204 | 204 | |
205 | - $this->constraintStore->deleteForProperty( $propertyId ); |
|
205 | + $this->constraintStore->deleteForProperty($propertyId); |
|
206 | 206 | |
207 | 207 | /** @var Property $property */ |
208 | 208 | $property = $propertyRevision->getEntity(); |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | $this->importConstraintsForProperty( |
211 | 211 | $property, |
212 | 212 | $this->constraintStore, |
213 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
213 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
214 | 214 | ); |
215 | 215 | |
216 | - $connection->endAtomic( __CLASS__ ); |
|
216 | + $connection->endAtomic(__CLASS__); |
|
217 | 217 | |
218 | 218 | return true; |
219 | 219 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param WANObjectCache $cache |
37 | 37 | * @param string $formatVersion The version of the API response format. |
38 | 38 | */ |
39 | - public function __construct( WANObjectCache $cache, $formatVersion ) { |
|
39 | + public function __construct(WANObjectCache $cache, $formatVersion) { |
|
40 | 40 | $this->cache = $cache; |
41 | 41 | $this->formatVersion = $formatVersion; |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param EntityId $entityId |
46 | 46 | * @return string cache key |
47 | 47 | */ |
48 | - public function makeKey( EntityId $entityId ) { |
|
48 | + public function makeKey(EntityId $entityId) { |
|
49 | 49 | return $this->cache->makeKey( |
50 | 50 | 'WikibaseQualityConstraints', // extension |
51 | 51 | 'checkConstraints', // action |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param mixed|null &$info |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$info = null ) { |
|
65 | - return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $info ); |
|
64 | + public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$info = null) { |
|
65 | + return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $info); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | * @param array $opts |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) { |
|
76 | - return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts ); |
|
75 | + public function set(EntityId $key, $value, $ttl = 0, array $opts = []) { |
|
76 | + return $this->cache->set($this->makeKey($key), $value, $ttl, $opts); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @param EntityId $key |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - public function delete( EntityId $key ) { |
|
84 | - return $this->cache->delete( $this->makeKey( $key ) ); |
|
83 | + public function delete(EntityId $key) { |
|
84 | + return $this->cache->delete($this->makeKey($key)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | |
85 | 85 | $language = $repo->getUserLanguage(); |
86 | 86 | $formatterOptions = new FormatterOptions(); |
87 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
88 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
87 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
88 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
89 | 89 | |
90 | 90 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
91 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language ); |
|
91 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language); |
|
92 | 92 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
93 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language ); |
|
93 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language); |
|
94 | 94 | |
95 | 95 | $checkResultsRenderer = new CheckResultsRenderer( |
96 | 96 | $repo->getEntityTitleLookup(), |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $name, |
109 | 109 | $entityIdParser, |
110 | 110 | $statementGuidValidator, |
111 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
111 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
112 | 112 | $resultsSource, |
113 | 113 | $checkResultsRenderer, |
114 | 114 | $dataFactory |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | CheckResultsRenderer $checkResultsRenderer, |
136 | 136 | IBufferingStatsdDataFactory $dataFactory |
137 | 137 | ) { |
138 | - parent::__construct( $main, $name ); |
|
138 | + parent::__construct($main, $name); |
|
139 | 139 | $this->entityIdParser = $entityIdParser; |
140 | 140 | $this->statementGuidValidator = $statementGuidValidator; |
141 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
142 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
141 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
142 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
143 | 143 | $this->resultsSource = $resultsSource; |
144 | 144 | $this->checkResultsRenderer = $checkResultsRenderer; |
145 | 145 | $this->dataFactory = $dataFactory; |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | $params = $this->extractRequestParams(); |
157 | 157 | |
158 | - $this->validateParameters( $params ); |
|
159 | - $entityIds = $this->parseEntityIds( $params ); |
|
160 | - $claimIds = $this->parseClaimIds( $params ); |
|
158 | + $this->validateParameters($params); |
|
159 | + $entityIds = $this->parseEntityIds($params); |
|
160 | + $claimIds = $this->parseClaimIds($params); |
|
161 | 161 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
162 | 162 | $statuses = $params[self::PARAM_STATUS]; |
163 | 163 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ) |
174 | 174 | )->getArray() |
175 | 175 | ); |
176 | - $this->resultBuilder->markSuccess( 1 ); |
|
176 | + $this->resultBuilder->markSuccess(1); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return EntityId[] |
183 | 183 | */ |
184 | - private function parseEntityIds( array $params ) { |
|
184 | + private function parseEntityIds(array $params) { |
|
185 | 185 | $ids = $params[self::PARAM_ID]; |
186 | 186 | |
187 | - if ( $ids === null ) { |
|
187 | + if ($ids === null) { |
|
188 | 188 | return []; |
189 | - } elseif ( $ids === [] ) { |
|
189 | + } elseif ($ids === []) { |
|
190 | 190 | $this->errorReporter->dieError( |
191 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
191 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
192 | 192 | } |
193 | 193 | |
194 | - return array_map( function ( $id ) { |
|
194 | + return array_map(function($id) { |
|
195 | 195 | try { |
196 | - return $this->entityIdParser->parse( $id ); |
|
197 | - } catch ( EntityIdParsingException $e ) { |
|
196 | + return $this->entityIdParser->parse($id); |
|
197 | + } catch (EntityIdParsingException $e) { |
|
198 | 198 | $this->errorReporter->dieError( |
199 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
199 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
200 | 200 | } |
201 | - }, $ids ); |
|
201 | + }, $ids); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -206,35 +206,35 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return string[] |
208 | 208 | */ |
209 | - private function parseClaimIds( array $params ) { |
|
209 | + private function parseClaimIds(array $params) { |
|
210 | 210 | $ids = $params[self::PARAM_CLAIM_ID]; |
211 | 211 | |
212 | - if ( $ids === null ) { |
|
212 | + if ($ids === null) { |
|
213 | 213 | return []; |
214 | - } elseif ( $ids === [] ) { |
|
214 | + } elseif ($ids === []) { |
|
215 | 215 | $this->errorReporter->dieError( |
216 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
216 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
217 | 217 | } |
218 | 218 | |
219 | - foreach ( $ids as $id ) { |
|
220 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
219 | + foreach ($ids as $id) { |
|
220 | + if (!$this->statementGuidValidator->validate($id)) { |
|
221 | 221 | $this->errorReporter->dieError( |
222 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
222 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | 226 | return $ids; |
227 | 227 | } |
228 | 228 | |
229 | - private function validateParameters( array $params ) { |
|
230 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
231 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
229 | + private function validateParameters(array $params) { |
|
230 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
231 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
232 | 232 | ) { |
233 | 233 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
234 | 234 | $this->errorReporter->dieError( |
235 | 235 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
236 | 236 | } |
237 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
237 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
238 | 238 | $paramId = self::PARAM_ID; |
239 | 239 | $paramClaimId = self::PARAM_CLAIM_ID; |
240 | 240 | $this->errorReporter->dieError( |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | ], |
276 | 276 | ApiBase::PARAM_ISMULTI => true, |
277 | 277 | ApiBase::PARAM_ALL => true, |
278 | - ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ), |
|
278 | + ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES), |
|
279 | 279 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
280 | 280 | ], |
281 | 281 | ]; |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | DelegatingConstraintChecker $delegatingConstraintChecker |
79 | 79 | ): self { |
80 | 80 | $repo = WikibaseRepo::getDefaultInstance(); |
81 | - $helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() ); |
|
81 | + $helperFactory = $repo->getApiHelperFactory(RequestContext::getMain()); |
|
82 | 82 | $language = $repo->getUserLanguage(); |
83 | 83 | |
84 | 84 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
85 | 85 | $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory |
86 | - ->getEntityIdFormatter( $language ); |
|
86 | + ->getEntityIdFormatter($language); |
|
87 | 87 | $formatterOptions = new FormatterOptions(); |
88 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
88 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
89 | 89 | $dataValueFormatter = $valueFormatterFactory |
90 | - ->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
90 | + ->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
91 | 91 | $violationMessageRenderer = new MultilingualTextViolationMessageRenderer( |
92 | 92 | $entityIdHtmlLinkFormatter, |
93 | 93 | $dataValueFormatter, |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | StatementGuidParser $statementGuidParser, |
124 | 124 | IBufferingStatsdDataFactory $dataFactory |
125 | 125 | ) { |
126 | - parent::__construct( $main, $name ); |
|
126 | + parent::__construct($main, $name); |
|
127 | 127 | |
128 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
128 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
129 | 129 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
130 | 130 | $this->violationMessageRenderer = $violationMessageRenderer; |
131 | 131 | $this->statementGuidParser = $statementGuidParser; |
@@ -140,39 +140,39 @@ discard block |
||
140 | 140 | $params = $this->extractRequestParams(); |
141 | 141 | $result = $this->getResult(); |
142 | 142 | |
143 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
144 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
143 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
144 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
145 | 145 | |
146 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
147 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
146 | + $this->checkPropertyIds($propertyIds, $result); |
|
147 | + $this->checkConstraintIds($constraintIds, $result); |
|
148 | 148 | |
149 | - $result->addValue( null, 'success', 1 ); |
|
149 | + $result->addValue(null, 'success', 1); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @param array|null $propertyIdSerializations |
154 | 154 | * @return PropertyId[] |
155 | 155 | */ |
156 | - private function parsePropertyIds( $propertyIdSerializations ) { |
|
157 | - if ( $propertyIdSerializations === null ) { |
|
156 | + private function parsePropertyIds($propertyIdSerializations) { |
|
157 | + if ($propertyIdSerializations === null) { |
|
158 | 158 | return []; |
159 | - } elseif ( empty( $propertyIdSerializations ) ) { |
|
159 | + } elseif (empty($propertyIdSerializations)) { |
|
160 | 160 | $this->apiErrorReporter->dieError( |
161 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
161 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
162 | 162 | 'no-data' |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | 166 | return array_map( |
167 | - function ( $propertyIdSerialization ) { |
|
167 | + function($propertyIdSerialization) { |
|
168 | 168 | try { |
169 | - return new PropertyId( $propertyIdSerialization ); |
|
170 | - } catch ( InvalidArgumentException $e ) { |
|
169 | + return new PropertyId($propertyIdSerialization); |
|
170 | + } catch (InvalidArgumentException $e) { |
|
171 | 171 | $this->apiErrorReporter->dieError( |
172 | 172 | "Invalid id: $propertyIdSerialization", |
173 | 173 | 'invalid-property-id', |
174 | 174 | 0, // default argument |
175 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
175 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
176 | 176 | ); |
177 | 177 | } |
178 | 178 | }, |
@@ -184,35 +184,35 @@ discard block |
||
184 | 184 | * @param array|null $constraintIds |
185 | 185 | * @return string[] |
186 | 186 | */ |
187 | - private function parseConstraintIds( $constraintIds ) { |
|
188 | - if ( $constraintIds === null ) { |
|
187 | + private function parseConstraintIds($constraintIds) { |
|
188 | + if ($constraintIds === null) { |
|
189 | 189 | return []; |
190 | - } elseif ( empty( $constraintIds ) ) { |
|
190 | + } elseif (empty($constraintIds)) { |
|
191 | 191 | $this->apiErrorReporter->dieError( |
192 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
192 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
193 | 193 | 'no-data' |
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | 197 | return array_map( |
198 | - function ( $constraintId ) { |
|
198 | + function($constraintId) { |
|
199 | 199 | try { |
200 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
201 | - if ( !$propertyId instanceof PropertyId ) { |
|
200 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
201 | + if (!$propertyId instanceof PropertyId) { |
|
202 | 202 | $this->apiErrorReporter->dieError( |
203 | 203 | "Invalid property ID: {$propertyId->getSerialization()}", |
204 | 204 | 'invalid-property-id', |
205 | 205 | 0, // default argument |
206 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
206 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
207 | 207 | ); |
208 | 208 | } |
209 | 209 | return $constraintId; |
210 | - } catch ( StatementGuidParsingException $e ) { |
|
210 | + } catch (StatementGuidParsingException $e) { |
|
211 | 211 | $this->apiErrorReporter->dieError( |
212 | 212 | "Invalid statement GUID: $constraintId", |
213 | 213 | 'invalid-guid', |
214 | 214 | 0, // default argument |
215 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
215 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
216 | 216 | ); |
217 | 217 | } |
218 | 218 | }, |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * @param PropertyId[] $propertyIds |
225 | 225 | * @param ApiResult $result |
226 | 226 | */ |
227 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ) { |
|
228 | - foreach ( $propertyIds as $propertyId ) { |
|
229 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
227 | + private function checkPropertyIds(array $propertyIds, ApiResult $result) { |
|
228 | + foreach ($propertyIds as $propertyId) { |
|
229 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
230 | 230 | $allConstraintExceptions = $this->delegatingConstraintChecker |
231 | - ->checkConstraintParametersOnPropertyId( $propertyId ); |
|
232 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
231 | + ->checkConstraintParametersOnPropertyId($propertyId); |
|
232 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
233 | 233 | $this->addConstraintParameterExceptionsToResult( |
234 | 234 | $constraintId, |
235 | 235 | $constraintParameterExceptions, |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | * @param string[] $constraintIds |
244 | 244 | * @param ApiResult $result |
245 | 245 | */ |
246 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ) { |
|
247 | - foreach ( $constraintIds as $constraintId ) { |
|
248 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
246 | + private function checkConstraintIds(array $constraintIds, ApiResult $result) { |
|
247 | + foreach ($constraintIds as $constraintId) { |
|
248 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
249 | 249 | // already checked as part of checkPropertyIds() |
250 | 250 | continue; |
251 | 251 | } |
252 | 252 | $constraintParameterExceptions = $this->delegatingConstraintChecker |
253 | - ->checkConstraintParametersOnConstraintId( $constraintId ); |
|
254 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
253 | + ->checkConstraintParametersOnConstraintId($constraintId); |
|
254 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -259,18 +259,18 @@ discard block |
||
259 | 259 | * @param PropertyId $propertyId |
260 | 260 | * @return string[] |
261 | 261 | */ |
262 | - private function getResultPathForPropertyId( PropertyId $propertyId ) { |
|
263 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
262 | + private function getResultPathForPropertyId(PropertyId $propertyId) { |
|
263 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | 267 | * @param string $constraintId |
268 | 268 | * @return string[] |
269 | 269 | */ |
270 | - private function getResultPathForConstraintId( $constraintId ) { |
|
271 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
270 | + private function getResultPathForConstraintId($constraintId) { |
|
271 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
272 | 272 | '@phan-var PropertyId $propertyId'; |
273 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
273 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | $constraintParameterExceptions, |
286 | 286 | ApiResult $result |
287 | 287 | ) { |
288 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
289 | - if ( $constraintParameterExceptions === null ) { |
|
288 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
289 | + if ($constraintParameterExceptions === null) { |
|
290 | 290 | $result->addValue( |
291 | 291 | $path, |
292 | 292 | self::KEY_STATUS, |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | $result->addValue( |
297 | 297 | $path, |
298 | 298 | self::KEY_STATUS, |
299 | - empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
299 | + empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
300 | 300 | ); |
301 | 301 | $result->addValue( |
302 | 302 | $path, |
303 | 303 | self::KEY_PROBLEMS, |
304 | - array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions ) |
|
304 | + array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions) |
|
305 | 305 | ); |
306 | 306 | } |
307 | 307 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param ConstraintParameterException $e |
313 | 313 | * @return string[] |
314 | 314 | */ |
315 | - private function formatConstraintParameterException( ConstraintParameterException $e ) { |
|
315 | + private function formatConstraintParameterException(ConstraintParameterException $e) { |
|
316 | 316 | return [ |
317 | 317 | self::KEY_MESSAGE_HTML => $this->violationMessageRenderer->render( |
318 | 318 | $e->getViolationMessage() |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | return [ |
346 | 346 | 'action=wbcheckconstraintparameters&propertyid=P247' |
347 | 347 | => 'apihelp-wbcheckconstraintparameters-example-propertyid-1', |
348 | - 'action=wbcheckconstraintparameters&' . |
|
349 | - 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' . |
|
348 | + 'action=wbcheckconstraintparameters&'. |
|
349 | + 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'. |
|
350 | 350 | 'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f' |
351 | 351 | => 'apihelp-wbcheckconstraintparameters-example-constraintid-2', |
352 | 352 | ]; |
@@ -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 ) { |
|
44 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
45 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
43 | + ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) { |
|
44 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
45 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
46 | 46 | $dbName = $propertySource->getDatabaseName(); |
47 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
47 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
48 | 48 | |
49 | - if ( $propertySource->getSourceName() !== $localEntitySourceName ) { |
|
50 | - throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
49 | + if ($propertySource->getSourceName() !== $localEntitySourceName) { |
|
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,9 +78,9 @@ discard block |
||
78 | 78 | ); |
79 | 79 | }, |
80 | 80 | |
81 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function ( MediaWikiServices $services ) { |
|
82 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
83 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
81 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
82 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
83 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
84 | 84 | |
85 | 85 | return new CheckResultDeserializer( |
86 | 86 | new ConstraintDeserializer(), |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | ); |
94 | 94 | }, |
95 | 95 | |
96 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function ( MediaWikiServices $services ) { |
|
96 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
97 | 97 | return new ViolationMessageSerializer(); |
98 | 98 | }, |
99 | 99 | |
100 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function ( MediaWikiServices $services ) { |
|
101 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
102 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
100 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
101 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
102 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
103 | 103 | |
104 | 104 | return new ViolationMessageDeserializer( |
105 | 105 | $entityIdParser, |
@@ -107,24 +107,24 @@ discard block |
||
107 | 107 | ); |
108 | 108 | }, |
109 | 109 | |
110 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function ( MediaWikiServices $services ) { |
|
110 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
111 | 111 | // TODO in the future, get DeserializerFactory from $services? |
112 | 112 | $repo = WikibaseRepo::getDefaultInstance(); |
113 | 113 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
114 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
114 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
115 | 115 | |
116 | 116 | return new ConstraintParameterParser( |
117 | 117 | $services->getMainConfig(), |
118 | 118 | $deserializerFactory, |
119 | - $entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri() |
|
119 | + $entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri() |
|
120 | 120 | ); |
121 | 121 | }, |
122 | 122 | |
123 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
123 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
124 | 124 | return new ConnectionCheckerHelper(); |
125 | 125 | }, |
126 | 126 | |
127 | - ConstraintsServices::RANGE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
127 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
128 | 128 | // TODO in the future, get UnitConverter from $services? |
129 | 129 | $repo = WikibaseRepo::getDefaultInstance(); |
130 | 130 | $unitConverter = $repo->getUnitConverter(); |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | ); |
136 | 136 | }, |
137 | 137 | |
138 | - ConstraintsServices::SPARQL_HELPER => function ( MediaWikiServices $services ) { |
|
139 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
140 | - if ( $endpoint === '' ) { |
|
138 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
139 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
140 | + if ($endpoint === '') { |
|
141 | 141 | return new DummySparqlHelper(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | // TODO get PropertyDataTypeLookup from $services |
145 | 145 | $repo = WikibaseRepo::getDefaultInstance(); |
146 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
147 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
146 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
147 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
148 | 148 | $propertyDataTypeLookup = $repo->getPropertyDataTypeLookup(); |
149 | 149 | |
150 | 150 | return new SparqlHelper( |
@@ -153,122 +153,122 @@ discard block |
||
153 | 153 | $entityIdParser, |
154 | 154 | $propertyDataTypeLookup, |
155 | 155 | $services->getMainWANObjectCache(), |
156 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
157 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
156 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
157 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
158 | 158 | $services->getStatsdDataFactory(), |
159 | - ConstraintsServices::getExpiryLock( $services ), |
|
159 | + ConstraintsServices::getExpiryLock($services), |
|
160 | 160 | ConstraintsServices::getLoggingHelper(), |
161 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
161 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
162 | 162 | $services->getHttpRequestFactory() |
163 | 163 | ); |
164 | 164 | }, |
165 | 165 | |
166 | - ConstraintsServices::TYPE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
166 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
167 | 167 | return new TypeCheckerHelper( |
168 | - WikibaseServices::getEntityLookup( $services ), |
|
168 | + WikibaseServices::getEntityLookup($services), |
|
169 | 169 | $services->getMainConfig(), |
170 | - ConstraintsServices::getSparqlHelper( $services ), |
|
170 | + ConstraintsServices::getSparqlHelper($services), |
|
171 | 171 | $services->getStatsdDataFactory() |
172 | 172 | ); |
173 | 173 | }, |
174 | 174 | |
175 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function ( MediaWikiServices $services ) { |
|
176 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
175 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
176 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
177 | 177 | |
178 | 178 | $config = $services->getMainConfig(); |
179 | 179 | $checkerMap = [ |
180 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
181 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
182 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
183 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
184 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
185 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
186 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
187 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
188 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
189 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
190 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
191 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
192 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
193 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
194 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
195 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
196 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
197 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
198 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
199 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
200 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
201 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
202 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
203 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
204 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
205 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
206 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
207 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
208 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
209 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
210 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
211 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
212 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
213 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
214 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
215 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
216 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
217 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
218 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
219 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
220 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
221 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
222 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
223 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
224 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
225 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
226 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
227 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
228 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
229 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
230 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
231 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
232 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
233 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
234 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
235 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
236 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
237 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
180 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
181 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
182 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
183 | + => ConstraintCheckerServices::getItemChecker($services), |
|
184 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
185 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
186 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
187 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
188 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
189 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
190 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
191 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
192 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
193 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
194 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
195 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
196 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
197 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
198 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
199 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
200 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
201 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
202 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
203 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
204 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
205 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
206 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
207 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
208 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
209 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
210 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
211 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
212 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
213 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
214 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
215 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
216 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
217 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
218 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
219 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
220 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
221 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
222 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
223 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
224 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
225 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
226 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
227 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
228 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
229 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
230 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
231 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
232 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
233 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
234 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
235 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
236 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
237 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
238 | 238 | ]; |
239 | 239 | |
240 | 240 | return new DelegatingConstraintChecker( |
241 | - WikibaseServices::getEntityLookup( $services ), |
|
241 | + WikibaseServices::getEntityLookup($services), |
|
242 | 242 | $checkerMap, |
243 | - ConstraintsServices::getConstraintLookup( $services ), |
|
244 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
243 | + ConstraintsServices::getConstraintLookup($services), |
|
244 | + ConstraintsServices::getConstraintParameterParser($services), |
|
245 | 245 | $statementGuidParser, |
246 | - ConstraintsServices::getLoggingHelper( $services ), |
|
247 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
248 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
249 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
246 | + ConstraintsServices::getLoggingHelper($services), |
|
247 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
248 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
249 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
250 | 250 | ); |
251 | 251 | }, |
252 | 252 | |
253 | - ConstraintsServices::RESULTS_SOURCE => function ( MediaWikiServices $services ) { |
|
253 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
254 | 254 | $config = $services->getMainConfig(); |
255 | 255 | $resultsSource = new CheckingResultsSource( |
256 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
256 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
257 | 257 | ); |
258 | 258 | |
259 | 259 | $cacheCheckConstraintsResults = false; |
260 | 260 | |
261 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
261 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
262 | 262 | $cacheCheckConstraintsResults = true; |
263 | 263 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
264 | 264 | // TODO we should always be able to cache constraint check results (T244726) |
265 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
266 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
265 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
266 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
267 | 267 | |
268 | - foreach ( $entitySources as $entitySource ) { |
|
269 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
270 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
271 | - 'Cannot cache constraint check results for non-local source: ' . |
|
268 | + foreach ($entitySources as $entitySource) { |
|
269 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
270 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
271 | + 'Cannot cache constraint check results for non-local source: '. |
|
272 | 272 | $entitySource->getSourceName() |
273 | 273 | ); |
274 | 274 | $cacheCheckConstraintsResults = false; |
@@ -277,29 +277,29 @@ discard block |
||
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - if ( $cacheCheckConstraintsResults ) { |
|
280 | + if ($cacheCheckConstraintsResults) { |
|
281 | 281 | $possiblyStaleConstraintTypes = [ |
282 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
283 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
284 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
285 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
282 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
283 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
284 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
285 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
286 | 286 | ]; |
287 | 287 | // TODO in the future, get WikiPageEntityMetaDataAccessor from $services? |
288 | 288 | $repo = WikibaseRepo::getDefaultInstance(); |
289 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
289 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
290 | 290 | $wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor(); |
291 | 291 | |
292 | 292 | $resultsSource = new CachingResultsSource( |
293 | 293 | $resultsSource, |
294 | 294 | ResultsCache::getDefaultInstance(), |
295 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
296 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
295 | + ConstraintsServices::getCheckResultSerializer($services), |
|
296 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
297 | 297 | $wikiPageEntityMetaDataAccessor, |
298 | 298 | $entityIdParser, |
299 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
299 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
300 | 300 | $possiblyStaleConstraintTypes, |
301 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
302 | - ConstraintsServices::getLoggingHelper( $services ) |
|
301 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
302 | + ConstraintsServices::getLoggingHelper($services) |
|
303 | 303 | ); |
304 | 304 | } |
305 | 305 |