@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | |
87 | 87 | $language = $repo->getUserLanguage(); |
88 | 88 | $formatterOptions = new FormatterOptions(); |
89 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
90 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
89 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
90 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
91 | 91 | |
92 | 92 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
93 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language ); |
|
93 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language); |
|
94 | 94 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
95 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language ); |
|
95 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language); |
|
96 | 96 | |
97 | 97 | $checkResultsRenderer = new CheckResultsRenderer( |
98 | 98 | $entityTitleLookup, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $name, |
111 | 111 | $entityIdParser, |
112 | 112 | $statementGuidValidator, |
113 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
113 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
114 | 114 | $resultsSource, |
115 | 115 | $checkResultsRenderer, |
116 | 116 | $dataFactory |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | CheckResultsRenderer $checkResultsRenderer, |
138 | 138 | IBufferingStatsdDataFactory $dataFactory |
139 | 139 | ) { |
140 | - parent::__construct( $main, $name ); |
|
140 | + parent::__construct($main, $name); |
|
141 | 141 | $this->entityIdParser = $entityIdParser; |
142 | 142 | $this->statementGuidValidator = $statementGuidValidator; |
143 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
144 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
143 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
144 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
145 | 145 | $this->resultsSource = $resultsSource; |
146 | 146 | $this->checkResultsRenderer = $checkResultsRenderer; |
147 | 147 | $this->dataFactory = $dataFactory; |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | |
158 | 158 | $params = $this->extractRequestParams(); |
159 | 159 | |
160 | - $this->validateParameters( $params ); |
|
161 | - $entityIds = $this->parseEntityIds( $params ); |
|
162 | - $claimIds = $this->parseClaimIds( $params ); |
|
160 | + $this->validateParameters($params); |
|
161 | + $entityIds = $this->parseEntityIds($params); |
|
162 | + $claimIds = $this->parseClaimIds($params); |
|
163 | 163 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
164 | 164 | $statuses = $params[self::PARAM_STATUS]; |
165 | 165 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ) |
176 | 176 | )->getArray() |
177 | 177 | ); |
178 | - $this->resultBuilder->markSuccess( 1 ); |
|
178 | + $this->resultBuilder->markSuccess(1); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,24 +183,24 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return EntityId[] |
185 | 185 | */ |
186 | - private function parseEntityIds( array $params ) { |
|
186 | + private function parseEntityIds(array $params) { |
|
187 | 187 | $ids = $params[self::PARAM_ID]; |
188 | 188 | |
189 | - if ( $ids === null ) { |
|
189 | + if ($ids === null) { |
|
190 | 190 | return []; |
191 | - } elseif ( $ids === [] ) { |
|
191 | + } elseif ($ids === []) { |
|
192 | 192 | $this->errorReporter->dieError( |
193 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
193 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
194 | 194 | } |
195 | 195 | |
196 | - return array_map( function ( $id ) { |
|
196 | + return array_map(function($id) { |
|
197 | 197 | try { |
198 | - return $this->entityIdParser->parse( $id ); |
|
199 | - } catch ( EntityIdParsingException $e ) { |
|
198 | + return $this->entityIdParser->parse($id); |
|
199 | + } catch (EntityIdParsingException $e) { |
|
200 | 200 | $this->errorReporter->dieError( |
201 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
201 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
202 | 202 | } |
203 | - }, $ids ); |
|
203 | + }, $ids); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -208,35 +208,35 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return string[] |
210 | 210 | */ |
211 | - private function parseClaimIds( array $params ) { |
|
211 | + private function parseClaimIds(array $params) { |
|
212 | 212 | $ids = $params[self::PARAM_CLAIM_ID]; |
213 | 213 | |
214 | - if ( $ids === null ) { |
|
214 | + if ($ids === null) { |
|
215 | 215 | return []; |
216 | - } elseif ( $ids === [] ) { |
|
216 | + } elseif ($ids === []) { |
|
217 | 217 | $this->errorReporter->dieError( |
218 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
218 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
219 | 219 | } |
220 | 220 | |
221 | - foreach ( $ids as $id ) { |
|
222 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
221 | + foreach ($ids as $id) { |
|
222 | + if (!$this->statementGuidValidator->validate($id)) { |
|
223 | 223 | $this->errorReporter->dieError( |
224 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
224 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | return $ids; |
229 | 229 | } |
230 | 230 | |
231 | - private function validateParameters( array $params ) { |
|
232 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
233 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
231 | + private function validateParameters(array $params) { |
|
232 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
233 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
234 | 234 | ) { |
235 | 235 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
236 | 236 | $this->errorReporter->dieError( |
237 | 237 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
238 | 238 | } |
239 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
239 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
240 | 240 | $paramId = self::PARAM_ID; |
241 | 241 | $paramClaimId = self::PARAM_CLAIM_ID; |
242 | 242 | $this->errorReporter->dieError( |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ], |
278 | 278 | ApiBase::PARAM_ISMULTI => true, |
279 | 279 | ApiBase::PARAM_ALL => true, |
280 | - ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ), |
|
280 | + ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES), |
|
281 | 281 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
282 | 282 | ], |
283 | 283 | ]; |
@@ -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,8 +50,8 @@ discard block |
||
50 | 50 | $services->getMainConfig(), |
51 | 51 | ConstraintsServices::getConstraintStore(), |
52 | 52 | $services->getDBLoadBalancerFactory(), |
53 | - $repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
54 | - WikibaseRepo::getBaseDataModelSerializerFactory( $services ) |
|
53 | + $repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
54 | + WikibaseRepo::getBaseDataModelSerializerFactory($services) |
|
55 | 55 | ->newSnakSerializer() |
56 | 56 | ); |
57 | 57 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | EntityRevisionLookup $entityRevisionLookup, |
112 | 112 | Serializer $snakSerializer |
113 | 113 | ) { |
114 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
114 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
115 | 115 | |
116 | 116 | $this->propertyId = $propertyId; |
117 | 117 | $this->revisionId = $revisionId; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $this->snakSerializer = $snakSerializer; |
123 | 123 | } |
124 | 124 | |
125 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
125 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
126 | 126 | $parameters = []; |
127 | - foreach ( $qualifiers as $qualifier ) { |
|
127 | + foreach ($qualifiers as $qualifier) { |
|
128 | 128 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
129 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
129 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
130 | 130 | $parameters[$qualifierId][] = $paramSerialization; |
131 | 131 | } |
132 | 132 | return $parameters; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | '@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue'; |
144 | 144 | $entityId = $dataValue->getEntityId(); |
145 | 145 | $constraintTypeQid = $entityId->getSerialization(); |
146 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
146 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
147 | 147 | return new Constraint( |
148 | 148 | $constraintId, |
149 | 149 | $propertyId, |
@@ -158,24 +158,24 @@ discard block |
||
158 | 158 | PropertyId $propertyConstraintPropertyId |
159 | 159 | ) { |
160 | 160 | $constraintsStatements = $property->getStatements() |
161 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
162 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
161 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
162 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
163 | 163 | $constraints = []; |
164 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
165 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
166 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
167 | - $constraintStore->insertBatch( $constraints ); |
|
164 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
165 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
166 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
167 | + $constraintStore->insertBatch($constraints); |
|
168 | 168 | // interrupt transaction and wait for replication |
169 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
170 | - $connection->endAtomic( __CLASS__ ); |
|
171 | - if ( !$connection->explicitTrxActive() ) { |
|
169 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
170 | + $connection->endAtomic(__CLASS__); |
|
171 | + if (!$connection->explicitTrxActive()) { |
|
172 | 172 | $this->lbFactory->waitForReplication(); |
173 | 173 | } |
174 | - $connection->startAtomic( __CLASS__ ); |
|
174 | + $connection->startAtomic(__CLASS__); |
|
175 | 175 | $constraints = []; |
176 | 176 | } |
177 | 177 | } |
178 | - $constraintStore->insertBatch( $constraints ); |
|
178 | + $constraintStore->insertBatch($constraints); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -186,24 +186,24 @@ discard block |
||
186 | 186 | public function run() { |
187 | 187 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
188 | 188 | |
189 | - $propertyId = new PropertyId( $this->propertyId ); |
|
189 | + $propertyId = new PropertyId($this->propertyId); |
|
190 | 190 | $propertyRevision = $this->entityRevisionLookup->getEntityRevision( |
191 | 191 | $propertyId, |
192 | 192 | 0, // latest |
193 | 193 | LookupConstants::LATEST_FROM_REPLICA |
194 | 194 | ); |
195 | 195 | |
196 | - if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) { |
|
197 | - JobQueueGroup::singleton()->push( $this ); |
|
196 | + if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) { |
|
197 | + JobQueueGroup::singleton()->push($this); |
|
198 | 198 | return true; |
199 | 199 | } |
200 | 200 | |
201 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
201 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
202 | 202 | // start transaction (if not started yet) – using __CLASS__, not __METHOD__, |
203 | 203 | // because importConstraintsForProperty() can interrupt the transaction |
204 | - $connection->startAtomic( __CLASS__ ); |
|
204 | + $connection->startAtomic(__CLASS__); |
|
205 | 205 | |
206 | - $this->constraintStore->deleteForProperty( $propertyId ); |
|
206 | + $this->constraintStore->deleteForProperty($propertyId); |
|
207 | 207 | |
208 | 208 | /** @var Property $property */ |
209 | 209 | $property = $propertyRevision->getEntity(); |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | $this->importConstraintsForProperty( |
212 | 212 | $property, |
213 | 213 | $this->constraintStore, |
214 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
214 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
215 | 215 | ); |
216 | 216 | |
217 | - $connection->endAtomic( __CLASS__ ); |
|
217 | + $connection->endAtomic(__CLASS__); |
|
218 | 218 | |
219 | 219 | return true; |
220 | 220 | } |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | use Wikibase\Repo\WikibaseRepo; |
18 | 18 | |
19 | 19 | // @codeCoverageIgnoreStart |
20 | -$basePath = getenv( "MW_INSTALL_PATH" ) !== false |
|
21 | - ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../.."; |
|
20 | +$basePath = getenv("MW_INSTALL_PATH") !== false |
|
21 | + ? getenv("MW_INSTALL_PATH") : __DIR__."/../../.."; |
|
22 | 22 | |
23 | -require_once $basePath . "/maintenance/Maintenance.php"; |
|
23 | +require_once $basePath."/maintenance/Maintenance.php"; |
|
24 | 24 | // @codeCoverageIgnoreEnd |
25 | 25 | |
26 | 26 | /** |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | parent::__construct(); |
60 | 60 | |
61 | 61 | $this->addDescription( |
62 | - 'Import entities needed for constraint checks ' . |
|
62 | + 'Import entities needed for constraint checks '. |
|
63 | 63 | 'from Wikidata into the local repository.' |
64 | 64 | ); |
65 | 65 | $this->addOption( |
66 | 66 | 'config-format', |
67 | - 'The format in which the resulting configuration will be omitted: ' . |
|
68 | - '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' . |
|
67 | + 'The format in which the resulting configuration will be omitted: '. |
|
68 | + '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '. |
|
69 | 69 | 'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.' |
70 | 70 | ); |
71 | 71 | $this->addOption( |
72 | 72 | 'dry-run', |
73 | 73 | 'Don’t actually import entities, just print which ones would be imported.' |
74 | 74 | ); |
75 | - $this->requireExtension( 'WikibaseQualityConstraints' ); |
|
75 | + $this->requireExtension('WikibaseQualityConstraints'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | private function setupServices() { |
82 | 82 | $services = MediaWikiServices::getInstance(); |
83 | 83 | $repo = WikibaseRepo::getDefaultInstance(); |
84 | - $this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer( $services ); |
|
84 | + $this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer($services); |
|
85 | 85 | $this->entityDeserializer = $repo->getInternalFormatEntityDeserializer(); |
86 | 86 | $this->entityStore = $repo->getEntityStore(); |
87 | 87 | $this->httpRequestFactory = $services->getHttpRequestFactory(); |
88 | - if ( !$this->getOption( 'dry-run', false ) ) { |
|
89 | - $this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' ); |
|
88 | + if (!$this->getOption('dry-run', false)) { |
|
89 | + $this->user = User::newSystemUser('WikibaseQualityConstraints importer'); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | |
96 | 96 | $configUpdates = []; |
97 | 97 | |
98 | - $extensionJsonFile = __DIR__ . '/../extension.json'; |
|
99 | - $extensionJsonText = file_get_contents( $extensionJsonFile ); |
|
100 | - $extensionJson = json_decode( $extensionJsonText, /* assoc = */ true ); |
|
98 | + $extensionJsonFile = __DIR__.'/../extension.json'; |
|
99 | + $extensionJsonText = file_get_contents($extensionJsonFile); |
|
100 | + $extensionJson = json_decode($extensionJsonText, /* assoc = */ true); |
|
101 | 101 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
102 | - $wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() ); |
|
102 | + $wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig()); |
|
103 | 103 | |
104 | - foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) { |
|
105 | - $localEntityId = $this->importEntityFromWikidata( $wikidataEntityId ); |
|
104 | + foreach ($wikidataEntityIds as $key => $wikidataEntityId) { |
|
105 | + $localEntityId = $this->importEntityFromWikidata($wikidataEntityId); |
|
106 | 106 | $configUpdates[$key] = [ |
107 | 107 | 'wikidata' => $wikidataEntityId, |
108 | 108 | 'local' => $localEntityId, |
109 | 109 | ]; |
110 | 110 | } |
111 | 111 | |
112 | - $this->outputConfigUpdates( $configUpdates ); |
|
112 | + $this->outputConfigUpdates($configUpdates); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * @param Config $wikiConfig |
118 | 118 | * @return string[] |
119 | 119 | */ |
120 | - private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) { |
|
120 | + private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) { |
|
121 | 121 | $wikidataEntityIds = []; |
122 | 122 | |
123 | - foreach ( $extensionJsonConfig as $key => $value ) { |
|
124 | - if ( !preg_match( '/Id$/', $key ) ) { |
|
123 | + foreach ($extensionJsonConfig as $key => $value) { |
|
124 | + if (!preg_match('/Id$/', $key)) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | 128 | $wikidataEntityId = $value['value']; |
129 | - $localEntityId = $wikiConfig->get( $key ); |
|
129 | + $localEntityId = $wikiConfig->get($key); |
|
130 | 130 | |
131 | - if ( $localEntityId === $wikidataEntityId ) { |
|
131 | + if ($localEntityId === $wikidataEntityId) { |
|
132 | 132 | $wikidataEntityIds[$key] = $wikidataEntityId; |
133 | 133 | } |
134 | 134 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @param string $wikidataEntityId |
141 | 141 | * @return string local entity ID |
142 | 142 | */ |
143 | - private function importEntityFromWikidata( $wikidataEntityId ) { |
|
143 | + private function importEntityFromWikidata($wikidataEntityId) { |
|
144 | 144 | $wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json"; |
145 | - $wikidataEntitiesJson = $this->httpRequestFactory->get( $wikidataEntityUrl, [], __METHOD__ ); |
|
146 | - return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ); |
|
145 | + $wikidataEntitiesJson = $this->httpRequestFactory->get($wikidataEntityUrl, [], __METHOD__); |
|
146 | + return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,24 +151,24 @@ discard block |
||
151 | 151 | * @param string $wikidataEntitiesJson |
152 | 152 | * @return string local entity ID |
153 | 153 | */ |
154 | - private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) { |
|
154 | + private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) { |
|
155 | 155 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
156 | - $wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId]; |
|
157 | - $wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray ); |
|
156 | + $wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId]; |
|
157 | + $wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray); |
|
158 | 158 | |
159 | - $wikidataEntity->setId( null ); |
|
159 | + $wikidataEntity->setId(null); |
|
160 | 160 | |
161 | - if ( $wikidataEntity instanceof StatementListProvider ) { |
|
161 | + if ($wikidataEntity instanceof StatementListProvider) { |
|
162 | 162 | $wikidataEntity->getStatements()->clear(); |
163 | 163 | } |
164 | 164 | |
165 | - if ( $wikidataEntity instanceof Item ) { |
|
166 | - $wikidataEntity->setSiteLinkList( new SiteLinkList() ); |
|
165 | + if ($wikidataEntity instanceof Item) { |
|
166 | + $wikidataEntity->setSiteLinkList(new SiteLinkList()); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( $this->getOption( 'dry-run', false ) ) { |
|
170 | - $wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) ); |
|
171 | - $this->output( $wikidataEntityJson . "\n" ); |
|
169 | + if ($this->getOption('dry-run', false)) { |
|
170 | + $wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity)); |
|
171 | + $this->output($wikidataEntityJson."\n"); |
|
172 | 172 | return "-$wikidataEntityId"; |
173 | 173 | } |
174 | 174 | |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | )->getEntity(); |
182 | 182 | |
183 | 183 | return $localEntity->getId()->getSerialization(); |
184 | - } catch ( StorageException $storageException ) { |
|
185 | - return $this->storageExceptionToEntityId( $storageException ); |
|
184 | + } catch (StorageException $storageException) { |
|
185 | + return $this->storageExceptionToEntityId($storageException); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - private function storageExceptionToEntityId( StorageException $storageException ) { |
|
189 | + private function storageExceptionToEntityId(StorageException $storageException) { |
|
190 | 190 | $message = $storageException->getMessage(); |
191 | 191 | // example messages: |
192 | 192 | // * Item [[Item:Q475|Q475]] already has label "as references" |
@@ -196,25 +196,25 @@ discard block |
||
196 | 196 | // * Property [[Property:P694|P694]] already has label "instance of" |
197 | 197 | // associated with language code en. |
198 | 198 | $pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/'; |
199 | - if ( preg_match( $pattern, $message, $matches ) ) { |
|
199 | + if (preg_match($pattern, $message, $matches)) { |
|
200 | 200 | return $matches[1]; |
201 | 201 | } else { |
202 | 202 | throw $storageException; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - private function outputConfigUpdates( array $configUpdates ) { |
|
207 | - $configFormat = $this->getOption( 'config-format', 'globals' ); |
|
208 | - switch ( $configFormat ) { |
|
206 | + private function outputConfigUpdates(array $configUpdates) { |
|
207 | + $configFormat = $this->getOption('config-format', 'globals'); |
|
208 | + switch ($configFormat) { |
|
209 | 209 | case 'globals': |
210 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
210 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
211 | 211 | break; |
212 | 212 | case 'wgConf': |
213 | - $this->outputConfigUpdatesWgConf( $configUpdates ); |
|
213 | + $this->outputConfigUpdatesWgConf($configUpdates); |
|
214 | 214 | break; |
215 | 215 | default: |
216 | - $this->error( "Invalid config format \"$configFormat\", using \"globals\"" ); |
|
217 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
216 | + $this->error("Invalid config format \"$configFormat\", using \"globals\""); |
|
217 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
218 | 218 | break; |
219 | 219 | } |
220 | 220 | } |
@@ -222,22 +222,22 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * @param array[] $configUpdates |
224 | 224 | */ |
225 | - private function outputConfigUpdatesGlobals( array $configUpdates ) { |
|
226 | - foreach ( $configUpdates as $key => $value ) { |
|
227 | - $localValueCode = var_export( $value['local'], true ); |
|
228 | - $this->output( "\$wg$key = $localValueCode;\n" ); |
|
225 | + private function outputConfigUpdatesGlobals(array $configUpdates) { |
|
226 | + foreach ($configUpdates as $key => $value) { |
|
227 | + $localValueCode = var_export($value['local'], true); |
|
228 | + $this->output("\$wg$key = $localValueCode;\n"); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * @param array[] $configUpdates |
234 | 234 | */ |
235 | - private function outputConfigUpdatesWgConf( array $configUpdates ) { |
|
236 | - foreach ( $configUpdates as $key => $value ) { |
|
237 | - $keyCode = var_export( "wg$key", true ); |
|
238 | - $wikidataValueCode = var_export( $value['wikidata'], true ); |
|
239 | - $localValueCode = var_export( $value['local'], true ); |
|
240 | - $wikiIdCode = var_export( wfWikiID(), true ); |
|
235 | + private function outputConfigUpdatesWgConf(array $configUpdates) { |
|
236 | + foreach ($configUpdates as $key => $value) { |
|
237 | + $keyCode = var_export("wg$key", true); |
|
238 | + $wikidataValueCode = var_export($value['wikidata'], true); |
|
239 | + $localValueCode = var_export($value['local'], true); |
|
240 | + $wikiIdCode = var_export(wfWikiID(), true); |
|
241 | 241 | $block = <<< EOF |
242 | 242 | $keyCode => [ |
243 | 243 | 'default' => $wikidataValueCode, |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | |
248 | 248 | EOF; |
249 | - $this->output( $block ); |
|
249 | + $this->output($block); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 |
@@ -36,189 +36,189 @@ |
||
36 | 36 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker; |
37 | 37 | |
38 | 38 | return [ |
39 | - ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function ( MediaWikiServices $services ) { |
|
39 | + ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function(MediaWikiServices $services) { |
|
40 | 40 | return new ConflictsWithChecker( |
41 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
42 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
41 | + ConstraintsServices::getConstraintParameterParser($services), |
|
42 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
43 | 43 | ); |
44 | 44 | }, |
45 | 45 | |
46 | - ConstraintCheckerServices::ITEM_CHECKER => function ( MediaWikiServices $services ) { |
|
46 | + ConstraintCheckerServices::ITEM_CHECKER => function(MediaWikiServices $services) { |
|
47 | 47 | return new ItemChecker( |
48 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
49 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
48 | + ConstraintsServices::getConstraintParameterParser($services), |
|
49 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
50 | 50 | ); |
51 | 51 | }, |
52 | 52 | |
53 | - ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function ( MediaWikiServices $services ) { |
|
53 | + ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function(MediaWikiServices $services) { |
|
54 | 54 | return new TargetRequiredClaimChecker( |
55 | - WikibaseServices::getEntityLookup( $services ), |
|
56 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
57 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
55 | + WikibaseServices::getEntityLookup($services), |
|
56 | + ConstraintsServices::getConstraintParameterParser($services), |
|
57 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
58 | 58 | ); |
59 | 59 | }, |
60 | 60 | |
61 | - ConstraintCheckerServices::SYMMETRIC_CHECKER => function ( MediaWikiServices $services ) { |
|
61 | + ConstraintCheckerServices::SYMMETRIC_CHECKER => function(MediaWikiServices $services) { |
|
62 | 62 | return new SymmetricChecker( |
63 | - WikibaseServices::getEntityLookupWithoutCache( $services ), |
|
64 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
63 | + WikibaseServices::getEntityLookupWithoutCache($services), |
|
64 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
65 | 65 | ); |
66 | 66 | }, |
67 | 67 | |
68 | - ConstraintCheckerServices::INVERSE_CHECKER => function ( MediaWikiServices $services ) { |
|
68 | + ConstraintCheckerServices::INVERSE_CHECKER => function(MediaWikiServices $services) { |
|
69 | 69 | return new InverseChecker( |
70 | - WikibaseServices::getEntityLookup( $services ), |
|
71 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
72 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
70 | + WikibaseServices::getEntityLookup($services), |
|
71 | + ConstraintsServices::getConstraintParameterParser($services), |
|
72 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
73 | 73 | ); |
74 | 74 | }, |
75 | 75 | |
76 | - ConstraintCheckerServices::QUALIFIER_CHECKER => function ( MediaWikiServices $services ) { |
|
76 | + ConstraintCheckerServices::QUALIFIER_CHECKER => function(MediaWikiServices $services) { |
|
77 | 77 | return new QualifierChecker(); |
78 | 78 | }, |
79 | 79 | |
80 | - ConstraintCheckerServices::QUALIFIERS_CHECKER => function ( MediaWikiServices $services ) { |
|
80 | + ConstraintCheckerServices::QUALIFIERS_CHECKER => function(MediaWikiServices $services) { |
|
81 | 81 | return new QualifiersChecker( |
82 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
82 | + ConstraintsServices::getConstraintParameterParser($services) |
|
83 | 83 | ); |
84 | 84 | }, |
85 | 85 | |
86 | - ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function ( MediaWikiServices $services ) { |
|
86 | + ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function(MediaWikiServices $services) { |
|
87 | 87 | return new MandatoryQualifiersChecker( |
88 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
88 | + ConstraintsServices::getConstraintParameterParser($services) |
|
89 | 89 | ); |
90 | 90 | }, |
91 | 91 | |
92 | - ConstraintCheckerServices::RANGE_CHECKER => function ( MediaWikiServices $services ) { |
|
92 | + ConstraintCheckerServices::RANGE_CHECKER => function(MediaWikiServices $services) { |
|
93 | 93 | return new RangeChecker( |
94 | - WikibaseServices::getPropertyDataTypeLookup( $services ), |
|
95 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
96 | - ConstraintsServices::getRangeCheckerHelper( $services ) |
|
94 | + WikibaseServices::getPropertyDataTypeLookup($services), |
|
95 | + ConstraintsServices::getConstraintParameterParser($services), |
|
96 | + ConstraintsServices::getRangeCheckerHelper($services) |
|
97 | 97 | ); |
98 | 98 | }, |
99 | 99 | |
100 | - ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function ( MediaWikiServices $services ) { |
|
100 | + ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function(MediaWikiServices $services) { |
|
101 | 101 | return new DiffWithinRangeChecker( |
102 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
103 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
102 | + ConstraintsServices::getConstraintParameterParser($services), |
|
103 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
104 | 104 | $services->getMainConfig() |
105 | 105 | ); |
106 | 106 | }, |
107 | 107 | |
108 | - ConstraintCheckerServices::TYPE_CHECKER => function ( MediaWikiServices $services ) { |
|
108 | + ConstraintCheckerServices::TYPE_CHECKER => function(MediaWikiServices $services) { |
|
109 | 109 | return new TypeChecker( |
110 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
111 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
110 | + ConstraintsServices::getConstraintParameterParser($services), |
|
111 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
112 | 112 | $services->getMainConfig() |
113 | 113 | ); |
114 | 114 | }, |
115 | 115 | |
116 | - ConstraintCheckerServices::VALUE_TYPE_CHECKER => function ( MediaWikiServices $services ) { |
|
116 | + ConstraintCheckerServices::VALUE_TYPE_CHECKER => function(MediaWikiServices $services) { |
|
117 | 117 | return new ValueTypeChecker( |
118 | - WikibaseServices::getEntityLookup( $services ), |
|
119 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
120 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
118 | + WikibaseServices::getEntityLookup($services), |
|
119 | + ConstraintsServices::getConstraintParameterParser($services), |
|
120 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
121 | 121 | $services->getMainConfig() |
122 | 122 | ); |
123 | 123 | }, |
124 | 124 | |
125 | - ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function ( MediaWikiServices $services ) { |
|
125 | + ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
126 | 126 | return new SingleValueChecker( |
127 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
127 | + ConstraintsServices::getConstraintParameterParser($services) |
|
128 | 128 | ); |
129 | 129 | }, |
130 | 130 | |
131 | - ConstraintCheckerServices::MULTI_VALUE_CHECKER => function ( MediaWikiServices $services ) { |
|
131 | + ConstraintCheckerServices::MULTI_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
132 | 132 | return new MultiValueChecker( |
133 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
133 | + ConstraintsServices::getConstraintParameterParser($services) |
|
134 | 134 | ); |
135 | 135 | }, |
136 | 136 | |
137 | - ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function ( MediaWikiServices $services ) { |
|
137 | + ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
138 | 138 | // TODO return a different, dummy implementation if SPARQL is not available |
139 | 139 | return new UniqueValueChecker( |
140 | - ConstraintsServices::getSparqlHelper( $services ) |
|
140 | + ConstraintsServices::getSparqlHelper($services) |
|
141 | 141 | ); |
142 | 142 | }, |
143 | 143 | |
144 | - ConstraintCheckerServices::FORMAT_CHECKER => function ( MediaWikiServices $services ) { |
|
144 | + ConstraintCheckerServices::FORMAT_CHECKER => function(MediaWikiServices $services) { |
|
145 | 145 | // TODO return a different, dummy implementation if SPARQL is not available |
146 | 146 | return new FormatChecker( |
147 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
147 | + ConstraintsServices::getConstraintParameterParser($services), |
|
148 | 148 | $services->getMainConfig(), |
149 | - ConstraintsServices::getSparqlHelper( $services ) |
|
149 | + ConstraintsServices::getSparqlHelper($services) |
|
150 | 150 | ); |
151 | 151 | }, |
152 | 152 | |
153 | - ConstraintCheckerServices::COMMONS_LINK_CHECKER => function ( MediaWikiServices $services ) { |
|
153 | + ConstraintCheckerServices::COMMONS_LINK_CHECKER => function(MediaWikiServices $services) { |
|
154 | 154 | $pageNameNormalizer = new MediaWikiPageNameNormalizer(); |
155 | 155 | return new CommonsLinkChecker( |
156 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
156 | + ConstraintsServices::getConstraintParameterParser($services), |
|
157 | 157 | $pageNameNormalizer |
158 | 158 | ); |
159 | 159 | }, |
160 | 160 | |
161 | - ConstraintCheckerServices::ONE_OF_CHECKER => function ( MediaWikiServices $services ) { |
|
161 | + ConstraintCheckerServices::ONE_OF_CHECKER => function(MediaWikiServices $services) { |
|
162 | 162 | return new OneOfChecker( |
163 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
163 | + ConstraintsServices::getConstraintParameterParser($services) |
|
164 | 164 | ); |
165 | 165 | }, |
166 | 166 | |
167 | - ConstraintCheckerServices::VALUE_ONLY_CHECKER => function ( MediaWikiServices $services ) { |
|
167 | + ConstraintCheckerServices::VALUE_ONLY_CHECKER => function(MediaWikiServices $services) { |
|
168 | 168 | return new ValueOnlyChecker(); |
169 | 169 | }, |
170 | 170 | |
171 | - ConstraintCheckerServices::REFERENCE_CHECKER => function ( MediaWikiServices $services ) { |
|
171 | + ConstraintCheckerServices::REFERENCE_CHECKER => function(MediaWikiServices $services) { |
|
172 | 172 | return new ReferenceChecker(); |
173 | 173 | }, |
174 | 174 | |
175 | - ConstraintCheckerServices::NO_BOUNDS_CHECKER => function ( MediaWikiServices $services ) { |
|
175 | + ConstraintCheckerServices::NO_BOUNDS_CHECKER => function(MediaWikiServices $services) { |
|
176 | 176 | return new NoBoundsChecker(); |
177 | 177 | }, |
178 | 178 | |
179 | - ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function ( MediaWikiServices $services ) { |
|
179 | + ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function(MediaWikiServices $services) { |
|
180 | 180 | return new AllowedUnitsChecker( |
181 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
182 | - WikibaseRepo::getUnitConverter( $services ) |
|
181 | + ConstraintsServices::getConstraintParameterParser($services), |
|
182 | + WikibaseRepo::getUnitConverter($services) |
|
183 | 183 | ); |
184 | 184 | }, |
185 | 185 | |
186 | - ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function ( MediaWikiServices $services ) { |
|
186 | + ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
187 | 187 | return new SingleBestValueChecker( |
188 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
188 | + ConstraintsServices::getConstraintParameterParser($services) |
|
189 | 189 | ); |
190 | 190 | }, |
191 | 191 | |
192 | - ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function ( MediaWikiServices $services ) { |
|
192 | + ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function(MediaWikiServices $services) { |
|
193 | 193 | return new EntityTypeChecker( |
194 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
194 | + ConstraintsServices::getConstraintParameterParser($services) |
|
195 | 195 | ); |
196 | 196 | }, |
197 | 197 | |
198 | - ConstraintCheckerServices::NONE_OF_CHECKER => function ( MediaWikiServices $services ) { |
|
198 | + ConstraintCheckerServices::NONE_OF_CHECKER => function(MediaWikiServices $services) { |
|
199 | 199 | return new NoneOfChecker( |
200 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
200 | + ConstraintsServices::getConstraintParameterParser($services) |
|
201 | 201 | ); |
202 | 202 | }, |
203 | 203 | |
204 | - ConstraintCheckerServices::INTEGER_CHECKER => function ( MediaWikiServices $services ) { |
|
204 | + ConstraintCheckerServices::INTEGER_CHECKER => function(MediaWikiServices $services) { |
|
205 | 205 | return new IntegerChecker(); |
206 | 206 | }, |
207 | 207 | |
208 | - ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function ( MediaWikiServices $services ) { |
|
208 | + ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function(MediaWikiServices $services) { |
|
209 | 209 | return new CitationNeededChecker(); |
210 | 210 | }, |
211 | 211 | |
212 | - ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function ( MediaWikiServices $services ) { |
|
212 | + ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function(MediaWikiServices $services) { |
|
213 | 213 | return new PropertyScopeChecker( |
214 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
214 | + ConstraintsServices::getConstraintParameterParser($services) |
|
215 | 215 | ); |
216 | 216 | }, |
217 | 217 | |
218 | - ConstraintCheckerServices::CONTEMPORARY_CHECKER => function ( MediaWikiServices $services ) { |
|
218 | + ConstraintCheckerServices::CONTEMPORARY_CHECKER => function(MediaWikiServices $services) { |
|
219 | 219 | return new ContemporaryChecker( |
220 | - WikibaseServices::getEntityLookup( $services ), |
|
221 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
220 | + WikibaseServices::getEntityLookup($services), |
|
221 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
222 | 222 | $services->getMainConfig() |
223 | 223 | ); |
224 | 224 | }, |
@@ -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,38 +107,38 @@ discard block |
||
107 | 107 | ); |
108 | 108 | }, |
109 | 109 | |
110 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function ( MediaWikiServices $services ) { |
|
111 | - $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services ); |
|
112 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
110 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
111 | + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services); |
|
112 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
113 | 113 | |
114 | 114 | return new ConstraintParameterParser( |
115 | 115 | $services->getMainConfig(), |
116 | 116 | $deserializerFactory, |
117 | - $entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri() |
|
117 | + $entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri() |
|
118 | 118 | ); |
119 | 119 | }, |
120 | 120 | |
121 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
121 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
122 | 122 | return new ConnectionCheckerHelper(); |
123 | 123 | }, |
124 | 124 | |
125 | - ConstraintsServices::RANGE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
125 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
126 | 126 | return new RangeCheckerHelper( |
127 | 127 | $services->getMainConfig(), |
128 | - WikibaseRepo::getUnitConverter( $services ) |
|
128 | + WikibaseRepo::getUnitConverter($services) |
|
129 | 129 | ); |
130 | 130 | }, |
131 | 131 | |
132 | - ConstraintsServices::SPARQL_HELPER => function ( MediaWikiServices $services ) { |
|
133 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
134 | - if ( $endpoint === '' ) { |
|
132 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
133 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
134 | + if ($endpoint === '') { |
|
135 | 135 | return new DummySparqlHelper(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | // TODO get PropertyDataTypeLookup from $services |
139 | 139 | $repo = WikibaseRepo::getDefaultInstance(); |
140 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
141 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
140 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
141 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
142 | 142 | $propertyDataTypeLookup = $repo->getPropertyDataTypeLookup(); |
143 | 143 | |
144 | 144 | return new SparqlHelper( |
@@ -147,122 +147,122 @@ discard block |
||
147 | 147 | $entityIdParser, |
148 | 148 | $propertyDataTypeLookup, |
149 | 149 | $services->getMainWANObjectCache(), |
150 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
151 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
150 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
151 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
152 | 152 | $services->getStatsdDataFactory(), |
153 | - ConstraintsServices::getExpiryLock( $services ), |
|
153 | + ConstraintsServices::getExpiryLock($services), |
|
154 | 154 | ConstraintsServices::getLoggingHelper(), |
155 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
155 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
156 | 156 | $services->getHttpRequestFactory() |
157 | 157 | ); |
158 | 158 | }, |
159 | 159 | |
160 | - ConstraintsServices::TYPE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
160 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
161 | 161 | return new TypeCheckerHelper( |
162 | - WikibaseServices::getEntityLookup( $services ), |
|
162 | + WikibaseServices::getEntityLookup($services), |
|
163 | 163 | $services->getMainConfig(), |
164 | - ConstraintsServices::getSparqlHelper( $services ), |
|
164 | + ConstraintsServices::getSparqlHelper($services), |
|
165 | 165 | $services->getStatsdDataFactory() |
166 | 166 | ); |
167 | 167 | }, |
168 | 168 | |
169 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function ( MediaWikiServices $services ) { |
|
170 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
169 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
170 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
171 | 171 | |
172 | 172 | $config = $services->getMainConfig(); |
173 | 173 | $checkerMap = [ |
174 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
175 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
176 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
177 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
178 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
179 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
180 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
181 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
182 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
183 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
184 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
185 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
186 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
187 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
188 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
189 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
190 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
191 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
192 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
193 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
194 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
195 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
196 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
197 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
198 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
199 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
200 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
201 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
202 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
203 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
204 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
205 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
206 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
207 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
208 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
209 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
210 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
211 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
212 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
213 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
214 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
215 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
216 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
217 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
218 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
219 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
220 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
221 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
222 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
223 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
224 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
225 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
226 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
227 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
228 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
229 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
230 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
231 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
174 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
175 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
176 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
177 | + => ConstraintCheckerServices::getItemChecker($services), |
|
178 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
179 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
180 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
181 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
182 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
183 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
184 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
185 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
186 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
187 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
188 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
189 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
190 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
191 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
192 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
193 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
194 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
195 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
196 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
197 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
198 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
199 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
200 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
201 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
202 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
203 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
204 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
205 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
206 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
207 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
208 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
209 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
210 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
211 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
212 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
213 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
214 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
215 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
216 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
217 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
218 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
219 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
220 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
221 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
222 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
223 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
224 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
225 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
226 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
227 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
228 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
229 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
230 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
231 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
232 | 232 | ]; |
233 | 233 | |
234 | 234 | return new DelegatingConstraintChecker( |
235 | - WikibaseServices::getEntityLookup( $services ), |
|
235 | + WikibaseServices::getEntityLookup($services), |
|
236 | 236 | $checkerMap, |
237 | - ConstraintsServices::getConstraintLookup( $services ), |
|
238 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
237 | + ConstraintsServices::getConstraintLookup($services), |
|
238 | + ConstraintsServices::getConstraintParameterParser($services), |
|
239 | 239 | $statementGuidParser, |
240 | - ConstraintsServices::getLoggingHelper( $services ), |
|
241 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
242 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
243 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
240 | + ConstraintsServices::getLoggingHelper($services), |
|
241 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
242 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
243 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
244 | 244 | ); |
245 | 245 | }, |
246 | 246 | |
247 | - ConstraintsServices::RESULTS_SOURCE => function ( MediaWikiServices $services ) { |
|
247 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
248 | 248 | $config = $services->getMainConfig(); |
249 | 249 | $resultsSource = new CheckingResultsSource( |
250 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
250 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
251 | 251 | ); |
252 | 252 | |
253 | 253 | $cacheCheckConstraintsResults = false; |
254 | 254 | |
255 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
255 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
256 | 256 | $cacheCheckConstraintsResults = true; |
257 | 257 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
258 | 258 | // TODO we should always be able to cache constraint check results (T244726) |
259 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
260 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
259 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
260 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
261 | 261 | |
262 | - foreach ( $entitySources as $entitySource ) { |
|
263 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
264 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
265 | - 'Cannot cache constraint check results for non-local source: ' . |
|
262 | + foreach ($entitySources as $entitySource) { |
|
263 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
264 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
265 | + 'Cannot cache constraint check results for non-local source: '. |
|
266 | 266 | $entitySource->getSourceName() |
267 | 267 | ); |
268 | 268 | $cacheCheckConstraintsResults = false; |
@@ -271,29 +271,29 @@ discard block |
||
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - if ( $cacheCheckConstraintsResults ) { |
|
274 | + if ($cacheCheckConstraintsResults) { |
|
275 | 275 | $possiblyStaleConstraintTypes = [ |
276 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
277 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
278 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
279 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
276 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
277 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
278 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
279 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
280 | 280 | ]; |
281 | 281 | // TODO in the future, get WikiPageEntityMetaDataAccessor from $services? |
282 | 282 | $repo = WikibaseRepo::getDefaultInstance(); |
283 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
283 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
284 | 284 | $wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor(); |
285 | 285 | |
286 | 286 | $resultsSource = new CachingResultsSource( |
287 | 287 | $resultsSource, |
288 | 288 | ResultsCache::getDefaultInstance(), |
289 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
290 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
289 | + ConstraintsServices::getCheckResultSerializer($services), |
|
290 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
291 | 291 | $wikiPageEntityMetaDataAccessor, |
292 | 292 | $entityIdParser, |
293 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
293 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
294 | 294 | $possiblyStaleConstraintTypes, |
295 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
296 | - ConstraintsServices::getLoggingHelper( $services ) |
|
295 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
296 | + ConstraintsServices::getLoggingHelper($services) |
|
297 | 297 | ); |
298 | 298 | } |
299 | 299 |