@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
| 30 | 30 | * @param LoggerInterface|null $logger |
| 31 | 31 | */ |
| 32 | - public function __construct( ILoadBalancer $lb, $dbName, ?LoggerInterface $logger = null ) { |
|
| 32 | + public function __construct(ILoadBalancer $lb, $dbName, ?LoggerInterface $logger = null) { |
|
| 33 | 33 | $this->lb = $lb; |
| 34 | 34 | $this->dbName = $dbName; |
| 35 | 35 | $this->logger = $logger ?? new NullLogger(); |
@@ -40,22 +40,22 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return Constraint[] |
| 42 | 42 | */ |
| 43 | - public function queryConstraintsForProperty( NumericPropertyId $propertyId ) { |
|
| 44 | - $dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->dbName ); |
|
| 43 | + public function queryConstraintsForProperty(NumericPropertyId $propertyId) { |
|
| 44 | + $dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA, [], $this->dbName); |
|
| 45 | 45 | |
| 46 | 46 | $results = $dbr->newSelectQueryBuilder() |
| 47 | - ->select( [ |
|
| 47 | + ->select([ |
|
| 48 | 48 | 'constraint_type_qid', |
| 49 | 49 | 'constraint_parameters', |
| 50 | 50 | 'constraint_guid', |
| 51 | 51 | 'pid', |
| 52 | - ] ) |
|
| 53 | - ->from( 'wbqc_constraints' ) |
|
| 54 | - ->where( [ 'pid' => $propertyId->getNumericId() ] ) |
|
| 55 | - ->caller( __METHOD__ ) |
|
| 52 | + ]) |
|
| 53 | + ->from('wbqc_constraints') |
|
| 54 | + ->where(['pid' => $propertyId->getNumericId()]) |
|
| 55 | + ->caller(__METHOD__) |
|
| 56 | 56 | ->fetchResultSet(); |
| 57 | 57 | |
| 58 | - return $this->convertToConstraints( $results ); |
|
| 58 | + return $this->convertToConstraints($results); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -63,25 +63,25 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return Constraint[] |
| 65 | 65 | */ |
| 66 | - private function convertToConstraints( IResultWrapper $results ) { |
|
| 66 | + private function convertToConstraints(IResultWrapper $results) { |
|
| 67 | 67 | $constraints = []; |
| 68 | - foreach ( $results as $result ) { |
|
| 68 | + foreach ($results as $result) { |
|
| 69 | 69 | $constraintTypeItemId = $result->constraint_type_qid; |
| 70 | - $constraintParameters = json_decode( $result->constraint_parameters, true ); |
|
| 70 | + $constraintParameters = json_decode($result->constraint_parameters, true); |
|
| 71 | 71 | |
| 72 | - if ( $constraintParameters === null ) { |
|
| 72 | + if ($constraintParameters === null) { |
|
| 73 | 73 | // T171295 |
| 74 | - $this->logger->warning( 'Constraint {constraintId} has invalid constraint parameters.', [ |
|
| 74 | + $this->logger->warning('Constraint {constraintId} has invalid constraint parameters.', [ |
|
| 75 | 75 | 'method' => __METHOD__, |
| 76 | 76 | 'constraintId' => $result->constraint_guid, |
| 77 | 77 | 'constraintParameters' => $result->constraint_parameters, |
| 78 | - ] ); |
|
| 79 | - $constraintParameters = [ '@error' => [ /* unknown */ ] ]; |
|
| 78 | + ]); |
|
| 79 | + $constraintParameters = ['@error' => [/* unknown */]]; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $constraints[] = new Constraint( |
| 83 | 83 | $result->constraint_guid, |
| 84 | - NumericPropertyId::newFromNumber( $result->pid ), |
|
| 84 | + NumericPropertyId::newFromNumber($result->pid), |
|
| 85 | 85 | $constraintTypeItemId, |
| 86 | 86 | $constraintParameters |
| 87 | 87 | ); |
@@ -31,58 +31,58 @@ discard block |
||
| 31 | 31 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
| 32 | 32 | |
| 33 | 33 | return [ |
| 34 | - ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ): ExpiryLock { |
|
| 35 | - return new ExpiryLock( $services->getObjectCacheFactory()->getInstance( CACHE_ANYTHING ) ); |
|
| 34 | + ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services): ExpiryLock { |
|
| 35 | + return new ExpiryLock($services->getObjectCacheFactory()->getInstance(CACHE_ANYTHING)); |
|
| 36 | 36 | }, |
| 37 | 37 | |
| 38 | - ConstraintsServices::LOGGER => static function ( MediaWikiServices $services ): LoggerInterface { |
|
| 39 | - return LoggerFactory::getInstance( 'WikibaseQualityConstraints' ); |
|
| 38 | + ConstraintsServices::LOGGER => static function(MediaWikiServices $services): LoggerInterface { |
|
| 39 | + return LoggerFactory::getInstance('WikibaseQualityConstraints'); |
|
| 40 | 40 | }, |
| 41 | 41 | |
| 42 | - ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ): LoggingHelper { |
|
| 42 | + ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services): LoggingHelper { |
|
| 43 | 43 | return new LoggingHelper( |
| 44 | 44 | $services->getStatsdDataFactory(), |
| 45 | - ConstraintsServices::getLogger( $services ), |
|
| 45 | + ConstraintsServices::getLogger($services), |
|
| 46 | 46 | $services->getMainConfig() |
| 47 | 47 | ); |
| 48 | 48 | }, |
| 49 | 49 | |
| 50 | - ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ): ConstraintRepositoryStore { |
|
| 51 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
| 52 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
| 53 | - if ( $propertySource === null ) { |
|
| 54 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
| 50 | + ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services): ConstraintRepositoryStore { |
|
| 51 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
| 52 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
| 53 | + if ($propertySource === null) { |
|
| 54 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
| 58 | - if ( $propertySource->getSourceName() !== $localEntitySourceName ) { |
|
| 59 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
| 57 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
| 58 | + if ($propertySource->getSourceName() !== $localEntitySourceName) { |
|
| 59 | + throw new RuntimeException('Can\'t get a ConstraintStore for a non local entity source.'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $dbName = $propertySource->getDatabaseName(); |
| 63 | 63 | return new ConstraintRepositoryStore( |
| 64 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
| 64 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
| 65 | 65 | $dbName |
| 66 | 66 | ); |
| 67 | 67 | }, |
| 68 | 68 | |
| 69 | - ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ): ConstraintLookup { |
|
| 70 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
| 71 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
| 72 | - if ( $propertySource === null ) { |
|
| 73 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
| 69 | + ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services): ConstraintLookup { |
|
| 70 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
| 71 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
| 72 | + if ($propertySource === null) { |
|
| 73 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $dbName = $propertySource->getDatabaseName(); |
| 77 | 77 | $rawLookup = new ConstraintRepositoryLookup( |
| 78 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
| 78 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
| 79 | 79 | $dbName, |
| 80 | - ConstraintsServices::getLogger( $services ) |
|
| 80 | + ConstraintsServices::getLogger($services) |
|
| 81 | 81 | ); |
| 82 | - return new CachingConstraintLookup( $rawLookup ); |
|
| 82 | + return new CachingConstraintLookup($rawLookup); |
|
| 83 | 83 | }, |
| 84 | 84 | |
| 85 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ): CheckResultSerializer { |
|
| 85 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services): CheckResultSerializer { |
|
| 86 | 86 | return new CheckResultSerializer( |
| 87 | 87 | new ConstraintSerializer( |
| 88 | 88 | false // constraint parameters are not exposed |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | ); |
| 94 | 94 | }, |
| 95 | 95 | |
| 96 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ): CheckResultDeserializer { |
|
| 97 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 98 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
| 96 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services): CheckResultDeserializer { |
|
| 97 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 98 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
| 99 | 99 | |
| 100 | 100 | return new CheckResultDeserializer( |
| 101 | 101 | new ConstraintDeserializer(), |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | }, |
| 110 | 110 | |
| 111 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function ( |
|
| 111 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function( |
|
| 112 | 112 | MediaWikiServices $services |
| 113 | 113 | ): ViolationMessageSerializer { |
| 114 | 114 | return new ViolationMessageSerializer(); |
| 115 | 115 | }, |
| 116 | 116 | |
| 117 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function ( |
|
| 117 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function( |
|
| 118 | 118 | MediaWikiServices $services |
| 119 | 119 | ): ViolationMessageDeserializer { |
| 120 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 121 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
| 120 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 121 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
| 122 | 122 | |
| 123 | 123 | return new ViolationMessageDeserializer( |
| 124 | 124 | $entityIdParser, |
@@ -126,40 +126,40 @@ discard block |
||
| 126 | 126 | ); |
| 127 | 127 | }, |
| 128 | 128 | |
| 129 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function ( |
|
| 129 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function( |
|
| 130 | 130 | MediaWikiServices $services |
| 131 | 131 | ): ConstraintParameterParser { |
| 132 | - $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services ); |
|
| 133 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
| 132 | + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services); |
|
| 133 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
| 134 | 134 | |
| 135 | 135 | return new ConstraintParameterParser( |
| 136 | 136 | $services->getMainConfig(), |
| 137 | 137 | $deserializerFactory, |
| 138 | - $entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri() |
|
| 138 | + $entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri() |
|
| 139 | 139 | ); |
| 140 | 140 | }, |
| 141 | 141 | |
| 142 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ): ConnectionCheckerHelper { |
|
| 142 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services): ConnectionCheckerHelper { |
|
| 143 | 143 | return new ConnectionCheckerHelper(); |
| 144 | 144 | }, |
| 145 | 145 | |
| 146 | - ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ): RangeCheckerHelper { |
|
| 146 | + ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services): RangeCheckerHelper { |
|
| 147 | 147 | return new RangeCheckerHelper( |
| 148 | 148 | $services->getMainConfig(), |
| 149 | - WikibaseRepo::getUnitConverter( $services ) |
|
| 149 | + WikibaseRepo::getUnitConverter($services) |
|
| 150 | 150 | ); |
| 151 | 151 | }, |
| 152 | 152 | |
| 153 | - ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ): SparqlHelper { |
|
| 154 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
| 155 | - if ( $endpoint === '' ) { |
|
| 153 | + ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services): SparqlHelper { |
|
| 154 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
| 155 | + if ($endpoint === '') { |
|
| 156 | 156 | return new DummySparqlHelper(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
| 160 | - $valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory( $services ); |
|
| 161 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 162 | - $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services ); |
|
| 159 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
| 160 | + $valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory($services); |
|
| 161 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 162 | + $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services); |
|
| 163 | 163 | |
| 164 | 164 | return new SparqlHelper( |
| 165 | 165 | $services->getMainConfig(), |
@@ -168,128 +168,128 @@ discard block |
||
| 168 | 168 | $entityIdParser, |
| 169 | 169 | $propertyDataTypeLookup, |
| 170 | 170 | $services->getMainWANObjectCache(), |
| 171 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
| 172 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
| 171 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
| 172 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
| 173 | 173 | $services->getStatsdDataFactory(), |
| 174 | - ConstraintsServices::getExpiryLock( $services ), |
|
| 175 | - ConstraintsServices::getLoggingHelper( $services ), |
|
| 176 | - WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . $services->getHttpRequestFactory()->getUserAgent(), |
|
| 174 | + ConstraintsServices::getExpiryLock($services), |
|
| 175 | + ConstraintsServices::getLoggingHelper($services), |
|
| 176 | + WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.$services->getHttpRequestFactory()->getUserAgent(), |
|
| 177 | 177 | $services->getHttpRequestFactory() |
| 178 | 178 | ); |
| 179 | 179 | }, |
| 180 | 180 | |
| 181 | - ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ): TypeCheckerHelper { |
|
| 181 | + ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services): TypeCheckerHelper { |
|
| 182 | 182 | return new TypeCheckerHelper( |
| 183 | - WikibaseServices::getEntityLookup( $services ), |
|
| 183 | + WikibaseServices::getEntityLookup($services), |
|
| 184 | 184 | $services->getMainConfig(), |
| 185 | - ConstraintsServices::getSparqlHelper( $services ), |
|
| 186 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ) |
|
| 185 | + ConstraintsServices::getSparqlHelper($services), |
|
| 186 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints') |
|
| 187 | 187 | ); |
| 188 | 188 | }, |
| 189 | 189 | |
| 190 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function ( |
|
| 190 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function( |
|
| 191 | 191 | MediaWikiServices $services |
| 192 | 192 | ): DelegatingConstraintChecker { |
| 193 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
| 193 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
| 194 | 194 | |
| 195 | 195 | $config = $services->getMainConfig(); |
| 196 | 196 | $checkerMap = [ |
| 197 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
| 198 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
| 199 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
| 200 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
| 201 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
| 202 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
| 203 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
| 204 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
| 205 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
| 206 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
| 207 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
| 208 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
| 209 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
| 210 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
| 211 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
| 212 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
| 213 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
| 214 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
| 215 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
| 216 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
| 217 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
| 218 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
| 219 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
| 220 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
| 221 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
| 222 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
| 223 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
| 224 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
| 225 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
| 226 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
| 227 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
| 228 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
| 229 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
| 230 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
| 231 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
| 232 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
| 233 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
| 234 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
| 235 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
| 236 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
| 237 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
| 238 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
| 239 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
| 240 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
| 241 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
| 242 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
| 243 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
| 244 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
| 245 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
| 246 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
| 247 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
| 248 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
| 249 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
| 250 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
| 251 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
| 252 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
| 253 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
| 254 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
| 255 | - $config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' ) |
|
| 256 | - => ConstraintCheckerServices::getLexemeLanguageChecker( $services ), |
|
| 257 | - $config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' ) |
|
| 258 | - => ConstraintCheckerServices::getLabelInLanguageChecker( $services ), |
|
| 197 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
| 198 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
| 199 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
| 200 | + => ConstraintCheckerServices::getItemChecker($services), |
|
| 201 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
| 202 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
| 203 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
| 204 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
| 205 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
| 206 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
| 207 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
| 208 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
| 209 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
| 210 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
| 211 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
| 212 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
| 213 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
| 214 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
| 215 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
| 216 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
| 217 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
| 218 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
| 219 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
| 220 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
| 221 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
| 222 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
| 223 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
| 224 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
| 225 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
| 226 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
| 227 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
| 228 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
| 229 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
| 230 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
| 231 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
| 232 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
| 233 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
| 234 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
| 235 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
| 236 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
| 237 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
| 238 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
| 239 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
| 240 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
| 241 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
| 242 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
| 243 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
| 244 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
| 245 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
| 246 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
| 247 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
| 248 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
| 249 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
| 250 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
| 251 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
| 252 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
| 253 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
| 254 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
| 255 | + $config->get('WBQualityConstraintsLexemeLanguageConstraintId') |
|
| 256 | + => ConstraintCheckerServices::getLexemeLanguageChecker($services), |
|
| 257 | + $config->get('WBQualityConstraintsLabelInLanguageConstraintId') |
|
| 258 | + => ConstraintCheckerServices::getLabelInLanguageChecker($services), |
|
| 259 | 259 | ]; |
| 260 | 260 | |
| 261 | 261 | return new DelegatingConstraintChecker( |
| 262 | - WikibaseServices::getEntityLookup( $services ), |
|
| 262 | + WikibaseServices::getEntityLookup($services), |
|
| 263 | 263 | $checkerMap, |
| 264 | - ConstraintsServices::getConstraintLookup( $services ), |
|
| 265 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
| 264 | + ConstraintsServices::getConstraintLookup($services), |
|
| 265 | + ConstraintsServices::getConstraintParameterParser($services), |
|
| 266 | 266 | $statementGuidParser, |
| 267 | - ConstraintsServices::getLoggingHelper( $services ), |
|
| 268 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
| 269 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
| 270 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
| 267 | + ConstraintsServices::getLoggingHelper($services), |
|
| 268 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
| 269 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
| 270 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
| 271 | 271 | ); |
| 272 | 272 | }, |
| 273 | 273 | |
| 274 | - ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ): ResultsSource { |
|
| 274 | + ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services): ResultsSource { |
|
| 275 | 275 | $config = $services->getMainConfig(); |
| 276 | 276 | $resultsSource = new CheckingResultsSource( |
| 277 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
| 277 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
| 278 | 278 | ); |
| 279 | 279 | |
| 280 | 280 | $cacheCheckConstraintsResults = false; |
| 281 | 281 | |
| 282 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
| 282 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
| 283 | 283 | $cacheCheckConstraintsResults = true; |
| 284 | 284 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
| 285 | 285 | // TODO we should always be able to cache constraint check results (T244726) |
| 286 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
| 287 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
| 286 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
| 287 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
| 288 | 288 | |
| 289 | - foreach ( $entitySources as $entitySource ) { |
|
| 290 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
| 291 | - ConstraintsServices::getLogger( $services )->warning( |
|
| 292 | - 'Cannot cache constraint check results for non-local source: ' . |
|
| 289 | + foreach ($entitySources as $entitySource) { |
|
| 290 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
| 291 | + ConstraintsServices::getLogger($services)->warning( |
|
| 292 | + 'Cannot cache constraint check results for non-local source: '. |
|
| 293 | 293 | $entitySource->getSourceName() |
| 294 | 294 | ); |
| 295 | 295 | $cacheCheckConstraintsResults = false; |
@@ -298,42 +298,42 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $cacheCheckConstraintsResults ) { |
|
| 301 | + if ($cacheCheckConstraintsResults) { |
|
| 302 | 302 | $possiblyStaleConstraintTypes = [ |
| 303 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
| 304 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
| 305 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
| 306 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
| 303 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
| 304 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
| 305 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
| 306 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
| 307 | 307 | ]; |
| 308 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 308 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 309 | 309 | $wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor( |
| 310 | 310 | $services ); |
| 311 | 311 | |
| 312 | 312 | $resultsSource = new CachingResultsSource( |
| 313 | 313 | $resultsSource, |
| 314 | 314 | ResultsCache::getDefaultInstance(), |
| 315 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
| 316 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
| 315 | + ConstraintsServices::getCheckResultSerializer($services), |
|
| 316 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
| 317 | 317 | $wikiPageEntityMetaDataAccessor, |
| 318 | 318 | $entityIdParser, |
| 319 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
| 319 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
| 320 | 320 | $possiblyStaleConstraintTypes, |
| 321 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
| 322 | - ConstraintsServices::getLoggingHelper( $services ) |
|
| 321 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
| 322 | + ConstraintsServices::getLoggingHelper($services) |
|
| 323 | 323 | ); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | return $resultsSource; |
| 327 | 327 | }, |
| 328 | 328 | |
| 329 | - ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function ( |
|
| 329 | + ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function( |
|
| 330 | 330 | MediaWikiServices $services |
| 331 | 331 | ): ViolationMessageRendererFactory { |
| 332 | 332 | return new ViolationMessageRendererFactory( |
| 333 | 333 | $services->getMainConfig(), |
| 334 | 334 | $services->getLanguageNameUtils(), |
| 335 | - WikibaseRepo::getEntityIdHtmlLinkFormatterFactory( $services ), |
|
| 336 | - WikibaseRepo::getValueFormatterFactory( $services ) |
|
| 335 | + WikibaseRepo::getEntityIdHtmlLinkFormatterFactory($services), |
|
| 336 | + WikibaseRepo::getValueFormatterFactory($services) |
|
| 337 | 337 | ); |
| 338 | 338 | }, |
| 339 | 339 | ]; |
@@ -42,95 +42,95 @@ |
||
| 42 | 42 | public const EXPIRY_LOCK = 'WBQC_ExpiryLock'; |
| 43 | 43 | public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory'; |
| 44 | 44 | |
| 45 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
| 45 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
| 46 | 46 | $services ??= MediaWikiServices::getInstance(); |
| 47 | - return $services->getService( $name ); |
|
| 47 | + return $services->getService($name); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public static function getLogger( ?MediaWikiServices $services = null ): LoggerInterface { |
|
| 51 | - return self::getService( $services, self::LOGGER ); |
|
| 50 | + public static function getLogger(?MediaWikiServices $services = null): LoggerInterface { |
|
| 51 | + return self::getService($services, self::LOGGER); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper { |
|
| 55 | - return self::getService( $services, self::LOGGING_HELPER ); |
|
| 54 | + public static function getLoggingHelper(?MediaWikiServices $services = null): LoggingHelper { |
|
| 55 | + return self::getService($services, self::LOGGING_HELPER); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public static function getConstraintStore( |
| 59 | 59 | ?MediaWikiServices $services = null |
| 60 | 60 | ): ConstraintStore { |
| 61 | - return self::getService( $services, self::CONSTRAINT_STORE ); |
|
| 61 | + return self::getService($services, self::CONSTRAINT_STORE); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup { |
|
| 65 | - return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
|
| 64 | + public static function getConstraintLookup(?MediaWikiServices $services = null): ConstraintLookup { |
|
| 65 | + return self::getService($services, self::CONSTRAINT_LOOKUP); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public static function getCheckResultSerializer( |
| 69 | 69 | ?MediaWikiServices $services = null |
| 70 | 70 | ): CheckResultSerializer { |
| 71 | - return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
|
| 71 | + return self::getService($services, self::CHECK_RESULT_SERIALIZER); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public static function getCheckResultDeserializer( |
| 75 | 75 | ?MediaWikiServices $services = null |
| 76 | 76 | ): CheckResultDeserializer { |
| 77 | - return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
|
| 77 | + return self::getService($services, self::CHECK_RESULT_DESERIALIZER); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public static function getViolationMessageSerializer( |
| 81 | 81 | ?MediaWikiServices $services = null |
| 82 | 82 | ): ViolationMessageSerializer { |
| 83 | - return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
|
| 83 | + return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public static function getViolationMessageDeserializer( |
| 87 | 87 | ?MediaWikiServices $services = null |
| 88 | 88 | ): ViolationMessageDeserializer { |
| 89 | - return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
|
| 89 | + return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | public static function getConstraintParameterParser( |
| 93 | 93 | ?MediaWikiServices $services = null |
| 94 | 94 | ): ConstraintParameterParser { |
| 95 | - return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
|
| 95 | + return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public static function getConnectionCheckerHelper( |
| 99 | 99 | ?MediaWikiServices $services = null |
| 100 | 100 | ): ConnectionCheckerHelper { |
| 101 | - return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
|
| 101 | + return self::getService($services, self::CONNECTION_CHECKER_HELPER); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper { |
|
| 105 | - return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
|
| 104 | + public static function getRangeCheckerHelper(?MediaWikiServices $services = null): RangeCheckerHelper { |
|
| 105 | + return self::getService($services, self::RANGE_CHECKER_HELPER); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper { |
|
| 109 | - return self::getService( $services, self::SPARQL_HELPER ); |
|
| 108 | + public static function getSparqlHelper(?MediaWikiServices $services = null): SparqlHelper { |
|
| 109 | + return self::getService($services, self::SPARQL_HELPER); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper { |
|
| 113 | - return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
|
| 112 | + public static function getTypeCheckerHelper(?MediaWikiServices $services = null): TypeCheckerHelper { |
|
| 113 | + return self::getService($services, self::TYPE_CHECKER_HELPER); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public static function getDelegatingConstraintChecker( |
| 117 | 117 | ?MediaWikiServices $services = null |
| 118 | 118 | ): DelegatingConstraintChecker { |
| 119 | - return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER ); |
|
| 119 | + return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource { |
|
| 123 | - return self::getService( $services, self::RESULTS_SOURCE ); |
|
| 122 | + public static function getResultsSource(?MediaWikiServices $services = null): ResultsSource { |
|
| 123 | + return self::getService($services, self::RESULTS_SOURCE); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock { |
|
| 127 | - return self::getService( $services, self::EXPIRY_LOCK ); |
|
| 126 | + public static function getExpiryLock(?MediaWikiServices $services = null): ExpiryLock { |
|
| 127 | + return self::getService($services, self::EXPIRY_LOCK); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public static function getViolationMessageRendererFactory( |
| 131 | 131 | ?MediaWikiServices $services = null |
| 132 | 132 | ): ViolationMessageRendererFactory { |
| 133 | - return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY ); |
|
| 133 | + return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | } |