@@ -27,28 +27,28 @@ discard block |
||
27 | 27 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
28 | 28 | |
29 | 29 | return [ |
30 | - ConstraintsServices::EXPIRY_LOCK => function( MediaWikiServices $services ) { |
|
31 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
30 | + ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) { |
|
31 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
32 | 32 | }, |
33 | 33 | |
34 | - ConstraintsServices::LOGGING_HELPER => function( MediaWikiServices $services ) { |
|
34 | + ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) { |
|
35 | 35 | return new LoggingHelper( |
36 | 36 | $services->getStatsdDataFactory(), |
37 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
37 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
38 | 38 | $services->getMainConfig() |
39 | 39 | ); |
40 | 40 | }, |
41 | 41 | |
42 | - ConstraintsServices::CONSTRAINT_REPOSITORY => function( MediaWikiServices $services ) { |
|
43 | - return new ConstraintRepository( $services->getDBLoadBalancer() ); |
|
42 | + ConstraintsServices::CONSTRAINT_REPOSITORY => function(MediaWikiServices $services) { |
|
43 | + return new ConstraintRepository($services->getDBLoadBalancer()); |
|
44 | 44 | }, |
45 | 45 | |
46 | - ConstraintsServices::CONSTRAINT_LOOKUP => function( MediaWikiServices $services ) { |
|
47 | - $constraintRepository = ConstraintsServices::getConstraintRepository( $services ); |
|
48 | - return new CachingConstraintLookup( $constraintRepository ); |
|
46 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
47 | + $constraintRepository = ConstraintsServices::getConstraintRepository($services); |
|
48 | + return new CachingConstraintLookup($constraintRepository); |
|
49 | 49 | }, |
50 | 50 | |
51 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) { |
|
51 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
52 | 52 | return new CheckResultSerializer( |
53 | 53 | new ConstraintSerializer( |
54 | 54 | false // constraint parameters are not exposed |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | }, |
61 | 61 | |
62 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) { |
|
62 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
63 | 63 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
64 | 64 | $repo = WikibaseRepo::getDefaultInstance(); |
65 | 65 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | ); |
77 | 77 | }, |
78 | 78 | |
79 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) { |
|
79 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
80 | 80 | return new ViolationMessageSerializer(); |
81 | 81 | }, |
82 | 82 | |
83 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) { |
|
83 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
84 | 84 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
85 | 85 | $repo = WikibaseRepo::getDefaultInstance(); |
86 | 86 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | ); |
93 | 93 | }, |
94 | 94 | |
95 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) { |
|
95 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
96 | 96 | // TODO in the future, get DeserializerFactory and concept base URIs from $services? |
97 | 97 | $repo = WikibaseRepo::getDefaultInstance(); |
98 | 98 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | ); |
106 | 106 | }, |
107 | 107 | |
108 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
108 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
109 | 109 | return new ConnectionCheckerHelper(); |
110 | 110 | }, |
111 | 111 | |
112 | - ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
112 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
113 | 113 | // TODO in the future, get UnitConverter from $services? |
114 | 114 | $repo = WikibaseRepo::getDefaultInstance(); |
115 | 115 | $unitConverter = $repo->getUnitConverter(); |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | ); |
121 | 121 | }, |
122 | 122 | |
123 | - ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) { |
|
124 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
125 | - if ( $endpoint === '' ) { |
|
123 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
124 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
125 | + if ($endpoint === '') { |
|
126 | 126 | return new DummySparqlHelper(); |
127 | 127 | } |
128 | 128 | |
@@ -138,117 +138,117 @@ discard block |
||
138 | 138 | $entityIdParser, |
139 | 139 | $propertyDataTypeLookup, |
140 | 140 | $services->getMainWANObjectCache(), |
141 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
142 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
141 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
142 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
143 | 143 | $services->getStatsdDataFactory(), |
144 | - ConstraintsServices::getExpiryLock( $services ), |
|
144 | + ConstraintsServices::getExpiryLock($services), |
|
145 | 145 | ConstraintsServices::getLoggingHelper(), |
146 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
146 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
147 | 147 | $services->getHttpRequestFactory() |
148 | 148 | ); |
149 | 149 | }, |
150 | 150 | |
151 | - ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
151 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
152 | 152 | return new TypeCheckerHelper( |
153 | - WikibaseServices::getEntityLookup( $services ), |
|
153 | + WikibaseServices::getEntityLookup($services), |
|
154 | 154 | $services->getMainConfig(), |
155 | - ConstraintsServices::getSparqlHelper( $services ), |
|
155 | + ConstraintsServices::getSparqlHelper($services), |
|
156 | 156 | $services->getStatsdDataFactory() |
157 | 157 | ); |
158 | 158 | }, |
159 | 159 | |
160 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) { |
|
160 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
161 | 161 | // TODO in the future, get StatementGuidParser from $services? |
162 | 162 | $repo = WikibaseRepo::getDefaultInstance(); |
163 | 163 | $statementGuidParser = $repo->getStatementGuidParser(); |
164 | 164 | |
165 | 165 | $config = $services->getMainConfig(); |
166 | 166 | $checkerMap = [ |
167 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
168 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
169 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
170 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
171 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
172 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
173 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
174 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
175 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
176 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
177 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
178 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
179 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
180 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
181 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
182 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
183 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
184 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
185 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
186 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
187 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
188 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
189 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
167 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
168 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
169 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
170 | + => ConstraintCheckerServices::getItemChecker($services), |
|
171 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
172 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
173 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
174 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
175 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
176 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
177 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
178 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
179 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
180 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
181 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
182 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
183 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
184 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
185 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
186 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
187 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
188 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
189 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
190 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
191 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
192 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
193 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
194 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
195 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
196 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
197 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
198 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
199 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
200 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
201 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
202 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
203 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
204 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
205 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
206 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
207 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
208 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
209 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
210 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
211 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
212 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
213 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
214 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
215 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
216 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
217 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
218 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
219 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
220 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
221 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
222 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
223 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
224 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
225 | 225 | ]; |
226 | 226 | |
227 | 227 | return new DelegatingConstraintChecker( |
228 | - WikibaseServices::getEntityLookup( $services ), |
|
228 | + WikibaseServices::getEntityLookup($services), |
|
229 | 229 | $checkerMap, |
230 | - ConstraintsServices::getConstraintLookup( $services ), |
|
231 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
230 | + ConstraintsServices::getConstraintLookup($services), |
|
231 | + ConstraintsServices::getConstraintParameterParser($services), |
|
232 | 232 | $statementGuidParser, |
233 | - ConstraintsServices::getLoggingHelper( $services ), |
|
234 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
235 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
236 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
233 | + ConstraintsServices::getLoggingHelper($services), |
|
234 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
235 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
236 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
237 | 237 | ); |
238 | 238 | }, |
239 | 239 | |
240 | - ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) { |
|
240 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
241 | 241 | $config = $services->getMainConfig(); |
242 | 242 | $resultsSource = new CheckingResultsSource( |
243 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
243 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
244 | 244 | ); |
245 | 245 | |
246 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
246 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
247 | 247 | $possiblyStaleConstraintTypes = [ |
248 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
249 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
250 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
251 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
248 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
249 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
250 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
251 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
252 | 252 | ]; |
253 | 253 | // TODO in the future, get EntityIdParser and WikiPageEntityMetaDataAccessor from $services? |
254 | 254 | $repo = WikibaseRepo::getDefaultInstance(); |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | $resultsSource = new CachingResultsSource( |
259 | 259 | $resultsSource, |
260 | 260 | ResultsCache::getDefaultInstance(), |
261 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
262 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
261 | + ConstraintsServices::getCheckResultSerializer($services), |
|
262 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
263 | 263 | $wikiPageEntityMetaDataAccessor, |
264 | 264 | $entityIdParser, |
265 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
265 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
266 | 266 | $possiblyStaleConstraintTypes, |
267 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
268 | - ConstraintsServices::getLoggingHelper( $services ) |
|
267 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
268 | + ConstraintsServices::getLoggingHelper($services) |
|
269 | 269 | ); |
270 | 270 | } |
271 | 271 |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | const BATCH_SIZE = 10; |
30 | 30 | |
31 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
32 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
31 | + public static function newFromGlobalState(Title $title, array $params) { |
|
32 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
33 | 33 | $repo = WikibaseRepo::getDefaultInstance(); |
34 | 34 | return new UpdateConstraintsTableJob( |
35 | 35 | $title, |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $params['revisionId'] ?? null, |
39 | 39 | MediaWikiServices::getInstance()->getMainConfig(), |
40 | 40 | ConstraintsServices::getConstraintRepository(), |
41 | - $repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
41 | + $repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
42 | 42 | $repo->getBaseDataModelSerializerFactory()->newSnakSerializer() |
43 | 43 | ); |
44 | 44 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | EntityRevisionLookup $entityRevisionLookup, |
94 | 94 | Serializer $snakSerializer |
95 | 95 | ) { |
96 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
96 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
97 | 97 | |
98 | 98 | $this->propertyId = $propertyId; |
99 | 99 | $this->revisionId = $revisionId; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | $this->snakSerializer = $snakSerializer; |
104 | 104 | } |
105 | 105 | |
106 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
106 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
107 | 107 | $parameters = []; |
108 | - foreach ( $qualifiers as $qualifier ) { |
|
108 | + foreach ($qualifiers as $qualifier) { |
|
109 | 109 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
110 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
110 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
111 | 111 | $parameters[$qualifierId][] = $paramSerialization; |
112 | 112 | } |
113 | 113 | return $parameters; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | ) { |
120 | 120 | $constraintId = $constraintStatement->getGuid(); |
121 | 121 | $constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization(); |
122 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
122 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
123 | 123 | return new Constraint( |
124 | 124 | $constraintId, |
125 | 125 | $propertyId, |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | PropertyId $propertyConstraintPropertyId |
135 | 135 | ) { |
136 | 136 | $constraintsStatements = $property->getStatements() |
137 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
138 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
137 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
138 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
139 | 139 | $constraints = []; |
140 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
141 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
142 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
143 | - $constraintRepo->insertBatch( $constraints ); |
|
140 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
141 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
142 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
143 | + $constraintRepo->insertBatch($constraints); |
|
144 | 144 | $constraints = []; |
145 | 145 | } |
146 | 146 | } |
147 | - $constraintRepo->insertBatch( $constraints ); |
|
147 | + $constraintRepo->insertBatch($constraints); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,26 +155,26 @@ discard block |
||
155 | 155 | public function run() { |
156 | 156 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
157 | 157 | |
158 | - $propertyId = new PropertyId( $this->propertyId ); |
|
158 | + $propertyId = new PropertyId($this->propertyId); |
|
159 | 159 | $propertyRevision = $this->entityRevisionLookup->getEntityRevision( |
160 | 160 | $propertyId, |
161 | 161 | 0, // latest |
162 | 162 | EntityRevisionLookup::LATEST_FROM_REPLICA |
163 | 163 | ); |
164 | 164 | |
165 | - if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) { |
|
166 | - JobQueueGroup::singleton()->push( $this ); |
|
165 | + if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) { |
|
166 | + JobQueueGroup::singleton()->push($this); |
|
167 | 167 | return true; |
168 | 168 | } |
169 | 169 | |
170 | - $this->constraintRepo->deleteForProperty( $propertyId ); |
|
170 | + $this->constraintRepo->deleteForProperty($propertyId); |
|
171 | 171 | |
172 | 172 | /** @var Property $property */ |
173 | 173 | $property = $propertyRevision->getEntity(); |
174 | 174 | $this->importConstraintsForProperty( |
175 | 175 | $property, |
176 | 176 | $this->constraintRepo, |
177 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
177 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
178 | 178 | ); |
179 | 179 | |
180 | 180 | return true; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** @var ILoadBalancer */ |
18 | 18 | private $lb; |
19 | 19 | |
20 | - public function __construct( ILoadBalancer $lb ) { |
|
20 | + public function __construct(ILoadBalancer $lb) { |
|
21 | 21 | $this->lb = $lb; |
22 | 22 | } |
23 | 23 | |
@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return Constraint[] |
28 | 28 | */ |
29 | - public function queryConstraintsForProperty( PropertyId $propertyId ) { |
|
30 | - $dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA ); |
|
29 | + public function queryConstraintsForProperty(PropertyId $propertyId) { |
|
30 | + $dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA); |
|
31 | 31 | |
32 | 32 | $results = $dbr->select( |
33 | 33 | 'wbqc_constraints', |
34 | 34 | '*', |
35 | - [ 'pid' => $propertyId->getNumericId() ] |
|
35 | + ['pid' => $propertyId->getNumericId()] |
|
36 | 36 | ); |
37 | 37 | |
38 | - return $this->convertToConstraints( $results ); |
|
38 | + return $this->convertToConstraints($results); |
|
39 | 39 | } |
40 | 40 | |
41 | - private function encodeConstraintParameters( array $constraintParameters ) { |
|
42 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
41 | + private function encodeConstraintParameters(array $constraintParameters) { |
|
42 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
43 | 43 | |
44 | - if ( strlen( $json ) > 50000 ) { |
|
45 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
44 | + if (strlen($json) > 50000) { |
|
45 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return $json; |
@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | * @throws DBUnexpectedError |
55 | 55 | * @return bool |
56 | 56 | */ |
57 | - public function insertBatch( array $constraints ) { |
|
57 | + public function insertBatch(array $constraints) { |
|
58 | 58 | $accumulator = array_map( |
59 | - function ( Constraint $constraint ) { |
|
59 | + function(Constraint $constraint) { |
|
60 | 60 | return [ |
61 | 61 | 'constraint_guid' => $constraint->getConstraintId(), |
62 | 62 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
63 | 63 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
64 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ) |
|
64 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()) |
|
65 | 65 | ]; |
66 | 66 | }, |
67 | 67 | $constraints |
68 | 68 | ); |
69 | 69 | |
70 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER ); |
|
71 | - return $dbw->insert( 'wbqc_constraints', $accumulator ); |
|
70 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER); |
|
71 | + return $dbw->insert('wbqc_constraints', $accumulator); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @throws DBUnexpectedError |
80 | 80 | */ |
81 | - public function deleteForProperty( PropertyId $propertyId ) { |
|
82 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER ); |
|
81 | + public function deleteForProperty(PropertyId $propertyId) { |
|
82 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER); |
|
83 | 83 | $dbw->delete( |
84 | 84 | 'wbqc_constraints', |
85 | 85 | [ |
@@ -93,26 +93,26 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return Constraint[] |
95 | 95 | */ |
96 | - private function convertToConstraints( IResultWrapper $results ) { |
|
96 | + private function convertToConstraints(IResultWrapper $results) { |
|
97 | 97 | $constraints = []; |
98 | - foreach ( $results as $result ) { |
|
98 | + foreach ($results as $result) { |
|
99 | 99 | $constraintTypeItemId = $result->constraint_type_qid; |
100 | - $constraintParameters = json_decode( $result->constraint_parameters, true ); |
|
100 | + $constraintParameters = json_decode($result->constraint_parameters, true); |
|
101 | 101 | |
102 | - if ( $constraintParameters === null ) { |
|
102 | + if ($constraintParameters === null) { |
|
103 | 103 | // T171295 |
104 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ) |
|
105 | - ->warning( 'Constraint {constraintId} has invalid constraint parameters.', [ |
|
104 | + LoggerFactory::getInstance('WikibaseQualityConstraints') |
|
105 | + ->warning('Constraint {constraintId} has invalid constraint parameters.', [ |
|
106 | 106 | 'method' => __METHOD__, |
107 | 107 | 'constraintId' => $result->constraint_guid, |
108 | 108 | 'constraintParameters' => $result->constraint_parameters, |
109 | - ] ); |
|
110 | - $constraintParameters = [ '@error' => [ /* unknown */ ] ]; |
|
109 | + ]); |
|
110 | + $constraintParameters = ['@error' => [/* unknown */]]; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $constraints[] = new Constraint( |
114 | 114 | $result->constraint_guid, |
115 | - PropertyId::newFromNumber( $result->pid ), |
|
115 | + PropertyId::newFromNumber($result->pid), |
|
116 | 116 | $constraintTypeItemId, |
117 | 117 | $constraintParameters |
118 | 118 | ); |