@@ -37,25 +37,25 @@ discard block |
||
37 | 37 | * @param Title $title |
38 | 38 | * @param string[] $params should contain 'entityId' => 'Q1234' |
39 | 39 | */ |
40 | - public function __construct( Title $title, array $params ) { |
|
41 | - parent::__construct( self::COMMAND, $title, $params ); |
|
40 | + public function __construct(Title $title, array $params) { |
|
41 | + parent::__construct(self::COMMAND, $title, $params); |
|
42 | 42 | $this->removeDuplicates = true; |
43 | 43 | |
44 | - Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' ); |
|
44 | + Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']'); |
|
45 | 45 | |
46 | - $resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() ); |
|
46 | + $resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance()); |
|
47 | 47 | '@phan-var CachingResultsSource $resultSource'; |
48 | 48 | // This job should only ever be used when caching result sources are used. |
49 | - $this->setResultsSource( $resultSource ); |
|
49 | + $this->setResultsSource($resultSource); |
|
50 | 50 | |
51 | - $this->setEntityIdParser( WikibaseRepo::getEntityIdParser() ); |
|
51 | + $this->setEntityIdParser(WikibaseRepo::getEntityIdParser()); |
|
52 | 52 | } |
53 | 53 | |
54 | - public function setResultsSource( CachingResultsSource $resultsSource ) { |
|
54 | + public function setResultsSource(CachingResultsSource $resultsSource) { |
|
55 | 55 | $this->resultsSource = $resultsSource; |
56 | 56 | } |
57 | 57 | |
58 | - public function setEntityIdParser( EntityIdParser $parser ) { |
|
58 | + public function setEntityIdParser(EntityIdParser $parser) { |
|
59 | 59 | $this->entityIdParser = $parser; |
60 | 60 | } |
61 | 61 | |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function run() { |
68 | 68 | try { |
69 | - $entityId = $this->entityIdParser->parse( $this->params['entityId'] ); |
|
70 | - } catch ( EntityIdParsingException $e ) { |
|
69 | + $entityId = $this->entityIdParser->parse($this->params['entityId']); |
|
70 | + } catch (EntityIdParsingException $e) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | |
74 | - $this->checkConstraints( $entityId ); |
|
74 | + $this->checkConstraints($entityId); |
|
75 | 75 | |
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | |
79 | - private function checkConstraints( EntityId $entityId ) { |
|
79 | + private function checkConstraints(EntityId $entityId) { |
|
80 | 80 | $this->resultsSource->getResults( |
81 | - [ $entityId ], |
|
81 | + [$entityId], |
|
82 | 82 | [], |
83 | 83 | null, |
84 | 84 | [] |
@@ -28,47 +28,47 @@ 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 ) { |
|
43 | + ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) { |
|
44 | 44 | $wbRepo = WikibaseRepo::getDefaultInstance(); |
45 | 45 | $sourceDefinitions = $wbRepo->getEntitySourceDefinitions(); |
46 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
46 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
47 | 47 | $dbName = $propertySource->getDatabaseName(); |
48 | 48 | |
49 | - if ( $propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName() ) { |
|
50 | - throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
49 | + if ($propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName()) { |
|
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 ) { |
|
59 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
60 | 60 | $wbRepo = WikibaseRepo::getDefaultInstance(); |
61 | 61 | $sourceDefinitions = $wbRepo->getEntitySourceDefinitions(); |
62 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
62 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
63 | 63 | $dbName = $propertySource->getDatabaseName(); |
64 | 64 | $rawLookup = new ConstraintRepositoryLookup( |
65 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
65 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
66 | 66 | $dbName |
67 | 67 | ); |
68 | - return new CachingConstraintLookup( $rawLookup ); |
|
68 | + return new CachingConstraintLookup($rawLookup); |
|
69 | 69 | }, |
70 | 70 | |
71 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) { |
|
71 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
72 | 72 | return new CheckResultSerializer( |
73 | 73 | new ConstraintSerializer( |
74 | 74 | false // constraint parameters are not exposed |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | ); |
80 | 80 | }, |
81 | 81 | |
82 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) { |
|
82 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
83 | 83 | // TODO in the future, get DataValueFactory from $services? |
84 | 84 | $repo = WikibaseRepo::getDefaultInstance(); |
85 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
85 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
86 | 86 | $dataValueFactory = $repo->getDataValueFactory(); |
87 | 87 | |
88 | 88 | return new CheckResultDeserializer( |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | ); |
97 | 97 | }, |
98 | 98 | |
99 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) { |
|
99 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
100 | 100 | return new ViolationMessageSerializer(); |
101 | 101 | }, |
102 | 102 | |
103 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) { |
|
103 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
104 | 104 | // TODO in the future, get DataValueFactory from $services? |
105 | 105 | $repo = WikibaseRepo::getDefaultInstance(); |
106 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
106 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
107 | 107 | $dataValueFactory = $repo->getDataValueFactory(); |
108 | 108 | |
109 | 109 | return new ViolationMessageDeserializer( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ); |
113 | 113 | }, |
114 | 114 | |
115 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) { |
|
115 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
116 | 116 | // TODO in the future, get DeserializerFactory and entity source definitions from $services? |
117 | 117 | $repo = WikibaseRepo::getDefaultInstance(); |
118 | 118 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | return new ConstraintParameterParser( |
122 | 122 | $services->getMainConfig(), |
123 | 123 | $deserializerFactory, |
124 | - $entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri() |
|
124 | + $entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri() |
|
125 | 125 | ); |
126 | 126 | }, |
127 | 127 | |
128 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
128 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
129 | 129 | return new ConnectionCheckerHelper(); |
130 | 130 | }, |
131 | 131 | |
132 | - ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
132 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
133 | 133 | // TODO in the future, get UnitConverter from $services? |
134 | 134 | $repo = WikibaseRepo::getDefaultInstance(); |
135 | 135 | $unitConverter = $repo->getUnitConverter(); |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | ); |
141 | 141 | }, |
142 | 142 | |
143 | - ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) { |
|
144 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
145 | - if ( $endpoint === '' ) { |
|
143 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
144 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
145 | + if ($endpoint === '') { |
|
146 | 146 | return new DummySparqlHelper(); |
147 | 147 | } |
148 | 148 | |
149 | 149 | // TODO in the future, get RDFVocabulary and PropertyDataTypeLookup from $services? |
150 | 150 | $repo = WikibaseRepo::getDefaultInstance(); |
151 | 151 | $rdfVocabulary = $repo->getRdfVocabulary(); |
152 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
152 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
153 | 153 | $propertyDataTypeLookup = $repo->getPropertyDataTypeLookup(); |
154 | 154 | |
155 | 155 | return new SparqlHelper( |
@@ -158,122 +158,122 @@ discard block |
||
158 | 158 | $entityIdParser, |
159 | 159 | $propertyDataTypeLookup, |
160 | 160 | $services->getMainWANObjectCache(), |
161 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
162 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
161 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
162 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
163 | 163 | $services->getStatsdDataFactory(), |
164 | - ConstraintsServices::getExpiryLock( $services ), |
|
164 | + ConstraintsServices::getExpiryLock($services), |
|
165 | 165 | ConstraintsServices::getLoggingHelper(), |
166 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
166 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
167 | 167 | $services->getHttpRequestFactory() |
168 | 168 | ); |
169 | 169 | }, |
170 | 170 | |
171 | - ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
171 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
172 | 172 | return new TypeCheckerHelper( |
173 | - WikibaseServices::getEntityLookup( $services ), |
|
173 | + WikibaseServices::getEntityLookup($services), |
|
174 | 174 | $services->getMainConfig(), |
175 | - ConstraintsServices::getSparqlHelper( $services ), |
|
175 | + ConstraintsServices::getSparqlHelper($services), |
|
176 | 176 | $services->getStatsdDataFactory() |
177 | 177 | ); |
178 | 178 | }, |
179 | 179 | |
180 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) { |
|
180 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
181 | 181 | // TODO in the future, get StatementGuidParser from $services? |
182 | 182 | $repo = WikibaseRepo::getDefaultInstance(); |
183 | 183 | $statementGuidParser = $repo->getStatementGuidParser(); |
184 | 184 | |
185 | 185 | $config = $services->getMainConfig(); |
186 | 186 | $checkerMap = [ |
187 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
188 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
189 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
225 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
226 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
227 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
228 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
229 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
230 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
231 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
232 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
233 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
234 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
235 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
236 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
237 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
238 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
239 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
240 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
241 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
242 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
243 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
244 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
187 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
188 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
189 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
190 | + => ConstraintCheckerServices::getItemChecker($services), |
|
191 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
192 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
193 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
194 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
195 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
196 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
197 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
198 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
199 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
200 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
201 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
202 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
203 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
204 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
205 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
206 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
207 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
208 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
209 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
210 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
211 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
212 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
213 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
214 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
215 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
216 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
217 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
218 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
219 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
220 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
221 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
222 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
223 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
224 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
225 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
226 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
227 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
228 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
229 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
230 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
231 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
232 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
233 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
234 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
235 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
236 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
237 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
238 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
239 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
240 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
241 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
242 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
243 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
244 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
245 | 245 | ]; |
246 | 246 | |
247 | 247 | return new DelegatingConstraintChecker( |
248 | - WikibaseServices::getEntityLookup( $services ), |
|
248 | + WikibaseServices::getEntityLookup($services), |
|
249 | 249 | $checkerMap, |
250 | - ConstraintsServices::getConstraintLookup( $services ), |
|
251 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
250 | + ConstraintsServices::getConstraintLookup($services), |
|
251 | + ConstraintsServices::getConstraintParameterParser($services), |
|
252 | 252 | $statementGuidParser, |
253 | - ConstraintsServices::getLoggingHelper( $services ), |
|
254 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
255 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
256 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
253 | + ConstraintsServices::getLoggingHelper($services), |
|
254 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
255 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
256 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
257 | 257 | ); |
258 | 258 | }, |
259 | 259 | |
260 | - ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) { |
|
260 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
261 | 261 | $config = $services->getMainConfig(); |
262 | 262 | $resultsSource = new CheckingResultsSource( |
263 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
263 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
264 | 264 | ); |
265 | 265 | |
266 | 266 | $cacheCheckConstraintsResults = false; |
267 | 267 | |
268 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
268 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
269 | 269 | $cacheCheckConstraintsResults = true; |
270 | 270 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
271 | 271 | // TODO we should always be able to cache constraint check results (T244726) |
272 | 272 | $repo = WikibaseRepo::getDefaultInstance(); |
273 | - foreach ( $repo->getEntitySourceDefinitions()->getSources() as $entitySource ) { |
|
274 | - if ( $entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName() ) { |
|
275 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
276 | - 'Cannot cache constraint check results for non-local source: ' . |
|
273 | + foreach ($repo->getEntitySourceDefinitions()->getSources() as $entitySource) { |
|
274 | + if ($entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName()) { |
|
275 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
276 | + 'Cannot cache constraint check results for non-local source: '. |
|
277 | 277 | $entitySource->getSourceName() |
278 | 278 | ); |
279 | 279 | $cacheCheckConstraintsResults = false; |
@@ -282,29 +282,29 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | - if ( $cacheCheckConstraintsResults ) { |
|
285 | + if ($cacheCheckConstraintsResults) { |
|
286 | 286 | $possiblyStaleConstraintTypes = [ |
287 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
288 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
289 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
290 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
287 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
288 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
289 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
290 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
291 | 291 | ]; |
292 | 292 | // TODO in the future, get WikiPageEntityMetaDataAccessor from $services? |
293 | 293 | $repo = WikibaseRepo::getDefaultInstance(); |
294 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
294 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
295 | 295 | $wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor(); |
296 | 296 | |
297 | 297 | $resultsSource = new CachingResultsSource( |
298 | 298 | $resultsSource, |
299 | 299 | ResultsCache::getDefaultInstance(), |
300 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
301 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
300 | + ConstraintsServices::getCheckResultSerializer($services), |
|
301 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
302 | 302 | $wikiPageEntityMetaDataAccessor, |
303 | 303 | $entityIdParser, |
304 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
304 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
305 | 305 | $possiblyStaleConstraintTypes, |
306 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
307 | - ConstraintsServices::getLoggingHelper( $services ) |
|
306 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
307 | + ConstraintsServices::getLoggingHelper($services) |
|
308 | 308 | ); |
309 | 309 | } |
310 | 310 |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | |
82 | 82 | $language = $repo->getUserLanguage(); |
83 | 83 | $formatterOptions = new FormatterOptions(); |
84 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
84 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
85 | 85 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
86 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
86 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
87 | 87 | |
88 | 88 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
89 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language ); |
|
89 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language); |
|
90 | 90 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
91 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language ); |
|
91 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language); |
|
92 | 92 | |
93 | 93 | $checkResultsRenderer = new CheckResultsRenderer( |
94 | 94 | $repo->getEntityTitleLookup(), |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $name, |
107 | 107 | $entityIdParser, |
108 | 108 | $repo->getStatementGuidValidator(), |
109 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
109 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
110 | 110 | $resultsSource, |
111 | 111 | $checkResultsRenderer, |
112 | 112 | $dataFactory |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | CheckResultsRenderer $checkResultsRenderer, |
134 | 134 | IBufferingStatsdDataFactory $dataFactory |
135 | 135 | ) { |
136 | - parent::__construct( $main, $name ); |
|
136 | + parent::__construct($main, $name); |
|
137 | 137 | $this->entityIdParser = $entityIdParser; |
138 | 138 | $this->statementGuidValidator = $statementGuidValidator; |
139 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
140 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
139 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
140 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
141 | 141 | $this->resultsSource = $resultsSource; |
142 | 142 | $this->checkResultsRenderer = $checkResultsRenderer; |
143 | 143 | $this->dataFactory = $dataFactory; |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | |
154 | 154 | $params = $this->extractRequestParams(); |
155 | 155 | |
156 | - $this->validateParameters( $params ); |
|
157 | - $entityIds = $this->parseEntityIds( $params ); |
|
158 | - $claimIds = $this->parseClaimIds( $params ); |
|
156 | + $this->validateParameters($params); |
|
157 | + $entityIds = $this->parseEntityIds($params); |
|
158 | + $claimIds = $this->parseClaimIds($params); |
|
159 | 159 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
160 | 160 | $statuses = $params[self::PARAM_STATUS]; |
161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ) |
172 | 172 | )->getArray() |
173 | 173 | ); |
174 | - $this->resultBuilder->markSuccess( 1 ); |
|
174 | + $this->resultBuilder->markSuccess(1); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,24 +179,24 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return EntityId[] |
181 | 181 | */ |
182 | - private function parseEntityIds( array $params ) { |
|
182 | + private function parseEntityIds(array $params) { |
|
183 | 183 | $ids = $params[self::PARAM_ID]; |
184 | 184 | |
185 | - if ( $ids === null ) { |
|
185 | + if ($ids === null) { |
|
186 | 186 | return []; |
187 | - } elseif ( $ids === [] ) { |
|
187 | + } elseif ($ids === []) { |
|
188 | 188 | $this->errorReporter->dieError( |
189 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
189 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
190 | 190 | } |
191 | 191 | |
192 | - return array_map( function ( $id ) { |
|
192 | + return array_map(function($id) { |
|
193 | 193 | try { |
194 | - return $this->entityIdParser->parse( $id ); |
|
195 | - } catch ( EntityIdParsingException $e ) { |
|
194 | + return $this->entityIdParser->parse($id); |
|
195 | + } catch (EntityIdParsingException $e) { |
|
196 | 196 | $this->errorReporter->dieError( |
197 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
197 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
198 | 198 | } |
199 | - }, $ids ); |
|
199 | + }, $ids); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -204,35 +204,35 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return string[] |
206 | 206 | */ |
207 | - private function parseClaimIds( array $params ) { |
|
207 | + private function parseClaimIds(array $params) { |
|
208 | 208 | $ids = $params[self::PARAM_CLAIM_ID]; |
209 | 209 | |
210 | - if ( $ids === null ) { |
|
210 | + if ($ids === null) { |
|
211 | 211 | return []; |
212 | - } elseif ( $ids === [] ) { |
|
212 | + } elseif ($ids === []) { |
|
213 | 213 | $this->errorReporter->dieError( |
214 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
214 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
215 | 215 | } |
216 | 216 | |
217 | - foreach ( $ids as $id ) { |
|
218 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
217 | + foreach ($ids as $id) { |
|
218 | + if (!$this->statementGuidValidator->validate($id)) { |
|
219 | 219 | $this->errorReporter->dieError( |
220 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
220 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | 224 | return $ids; |
225 | 225 | } |
226 | 226 | |
227 | - private function validateParameters( array $params ) { |
|
228 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
229 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
227 | + private function validateParameters(array $params) { |
|
228 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
229 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
230 | 230 | ) { |
231 | 231 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
232 | 232 | $this->errorReporter->dieError( |
233 | 233 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
234 | 234 | } |
235 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
235 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
236 | 236 | $paramId = self::PARAM_ID; |
237 | 237 | $paramClaimId = self::PARAM_CLAIM_ID; |
238 | 238 | $this->errorReporter->dieError( |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | ], |
274 | 274 | ApiBase::PARAM_ISMULTI => true, |
275 | 275 | ApiBase::PARAM_ALL => true, |
276 | - ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ), |
|
276 | + ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES), |
|
277 | 277 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
278 | 278 | ], |
279 | 279 | ]; |