@@ -28,27 +28,27 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @param DatabaseUpdater $updater |
30 | 30 | */ |
31 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
32 | - $dir = dirname( __DIR__ ) . '/sql/'; |
|
31 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
32 | + $dir = dirname(__DIR__).'/sql/'; |
|
33 | 33 | |
34 | 34 | $updater->addExtensionTable( |
35 | 35 | 'wbqc_constraints', |
36 | - $dir . "/{$updater->getDB()->getType()}/tables-generated.sql" |
|
36 | + $dir."/{$updater->getDB()->getType()}/tables-generated.sql" |
|
37 | 37 | ); |
38 | 38 | $updater->addExtensionField( |
39 | 39 | 'wbqc_constraints', |
40 | 40 | 'constraint_id', |
41 | - $dir . '/patch-wbqc_constraints-constraint_id.sql' |
|
41 | + $dir.'/patch-wbqc_constraints-constraint_id.sql' |
|
42 | 42 | ); |
43 | 43 | $updater->addExtensionIndex( |
44 | 44 | 'wbqc_constraints', |
45 | 45 | 'wbqc_constraints_guid_uniq', |
46 | - $dir . '/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
46 | + $dir.'/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
50 | - public static function onWikibaseChange( Change $change ) { |
|
51 | - if ( !( $change instanceof EntityChange ) ) { |
|
50 | + public static function onWikibaseChange(Change $change) { |
|
51 | + if (!($change instanceof EntityChange)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -57,48 +57,48 @@ discard block |
||
57 | 57 | |
58 | 58 | // If jobs are enabled and the results would be stored in some way run a job. |
59 | 59 | if ( |
60 | - $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) && |
|
61 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) && |
|
60 | + $config->get('WBQualityConstraintsEnableConstraintsCheckJobs') && |
|
61 | + $config->get('WBQualityConstraintsCacheCheckConstraintsResults') && |
|
62 | 62 | self::isSelectedForJobRunBasedOnPercentage() |
63 | 63 | ) { |
64 | - $params = [ 'entityId' => $change->getEntityId()->getSerialization() ]; |
|
64 | + $params = ['entityId' => $change->getEntityId()->getSerialization()]; |
|
65 | 65 | JobQueueGroup::singleton()->lazyPush( |
66 | - new JobSpecification( CheckConstraintsJob::COMMAND, $params ) |
|
66 | + new JobSpecification(CheckConstraintsJob::COMMAND, $params) |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
70 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
71 | - self::isConstraintStatementsChange( $config, $change ) |
|
70 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
71 | + self::isConstraintStatementsChange($config, $change) |
|
72 | 72 | ) { |
73 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
73 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
74 | 74 | $metadata = $change->getMetadata(); |
75 | - if ( array_key_exists( 'rev_id', $metadata ) ) { |
|
75 | + if (array_key_exists('rev_id', $metadata)) { |
|
76 | 76 | $params['revisionId'] = $metadata['rev_id']; |
77 | 77 | } |
78 | 78 | JobQueueGroup::singleton()->push( |
79 | - new JobSpecification( 'constraintsTableUpdate', $params ) |
|
79 | + new JobSpecification('constraintsTableUpdate', $params) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | 84 | private static function isSelectedForJobRunBasedOnPercentage() { |
85 | 85 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
86 | - $percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' ); |
|
86 | + $percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio'); |
|
87 | 87 | |
88 | - return mt_rand( 1, 100 ) <= $percentage; |
|
88 | + return mt_rand(1, 100) <= $percentage; |
|
89 | 89 | } |
90 | 90 | |
91 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
92 | - if ( !( $change instanceof EntityChange ) || |
|
91 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
92 | + if (!($change instanceof EntityChange) || |
|
93 | 93 | $change->getAction() !== EntityChange::UPDATE || |
94 | - !( $change->getEntityId() instanceof PropertyId ) |
|
94 | + !($change->getEntityId() instanceof PropertyId) |
|
95 | 95 | ) { |
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $info = $change->getInfo(); |
100 | 100 | |
101 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
101 | + if (!array_key_exists('compactDiff', $info)) { |
|
102 | 102 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
103 | 103 | // so we only know that the change *might* affect the constraint statements |
104 | 104 | return true; |
@@ -107,47 +107,47 @@ discard block |
||
107 | 107 | /** @var EntityDiffChangedAspects $aspects */ |
108 | 108 | $aspects = $info['compactDiff']; |
109 | 109 | |
110 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
111 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
110 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
111 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
112 | 112 | } |
113 | 113 | |
114 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
114 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
115 | 115 | $repo = WikibaseRepo::getDefaultInstance(); |
116 | 116 | |
117 | 117 | $entityContentFactory = $repo->getEntityContentFactory(); |
118 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
118 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
119 | 119 | $entityIdLookup = $repo->getEntityIdLookup(); |
120 | - $entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
121 | - if ( $entityId !== null ) { |
|
120 | + $entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle()); |
|
121 | + if ($entityId !== null) { |
|
122 | 122 | $resultsCache = ResultsCache::getDefaultInstance(); |
123 | - $resultsCache->delete( $entityId ); |
|
123 | + $resultsCache->delete($entityId); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
128 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
129 | 129 | $repo = WikibaseRepo::getDefaultInstance(); |
130 | 130 | |
131 | 131 | $lookup = $repo->getEntityNamespaceLookup(); |
132 | 132 | $title = $out->getTitle(); |
133 | - if ( $title === null ) { |
|
133 | + if ($title === null) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) { |
|
137 | + if (!$lookup->isNamespaceWithEntities($title->getNamespace())) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
140 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
144 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
145 | 145 | |
146 | - if ( !$out->getUser()->isRegistered() ) { |
|
146 | + if (!$out->getUser()->isRegistered()) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
150 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | } |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | use Wikimedia\Rdbms\ILBFactory; |
12 | 12 | |
13 | 13 | // @codeCoverageIgnoreStart |
14 | -$basePath = getenv( "MW_INSTALL_PATH" ) !== false |
|
15 | - ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../.."; |
|
14 | +$basePath = getenv("MW_INSTALL_PATH") !== false |
|
15 | + ? getenv("MW_INSTALL_PATH") : __DIR__."/../../.."; |
|
16 | 16 | |
17 | -require_once $basePath . "/maintenance/Maintenance.php"; |
|
17 | +require_once $basePath."/maintenance/Maintenance.php"; |
|
18 | 18 | // @codeCoverageIgnoreEnd |
19 | 19 | |
20 | 20 | /** |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | |
47 | 47 | public function __construct() { |
48 | 48 | parent::__construct(); |
49 | - $this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) { |
|
49 | + $this->newUpdateConstraintsTableJob = function($propertyIdSerialization) { |
|
50 | 50 | return UpdateConstraintsTableJob::newFromGlobalState( |
51 | 51 | Title::newMainPage(), |
52 | - [ 'propertyId' => $propertyIdSerialization ] |
|
52 | + ['propertyId' => $propertyIdSerialization] |
|
53 | 53 | ); |
54 | 54 | }; |
55 | 55 | |
56 | - $this->addDescription( 'Imports property constraints from statements on properties' ); |
|
57 | - $this->requireExtension( 'WikibaseQualityConstraints' ); |
|
58 | - $this->setBatchSize( 10 ); |
|
56 | + $this->addDescription('Imports property constraints from statements on properties'); |
|
57 | + $this->requireExtension('WikibaseQualityConstraints'); |
|
58 | + $this->setBatchSize(10); |
|
59 | 59 | |
60 | 60 | // Wikibase classes are not yet loaded, so setup services in a callback run in execute |
61 | 61 | // that can be overridden in tests. |
62 | - $this->setupServices = function () { |
|
62 | + $this->setupServices = function() { |
|
63 | 63 | $repo = WikibaseRepo::getDefaultInstance(); |
64 | 64 | $this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup(); |
65 | 65 | $this->lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); |
@@ -67,36 +67,36 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public function execute() { |
70 | - ( $this->setupServices )(); |
|
71 | - if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) { |
|
72 | - $this->error( 'Constraint statements are not enabled. Aborting.' ); |
|
70 | + ($this->setupServices)(); |
|
71 | + if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) { |
|
72 | + $this->error('Constraint statements are not enabled. Aborting.'); |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | $propertyInfos = $this->propertyInfoLookup->getAllPropertyInfo(); |
77 | - $propertyIds = array_keys( $propertyInfos ); |
|
77 | + $propertyIds = array_keys($propertyInfos); |
|
78 | 78 | |
79 | - foreach ( array_chunk( $propertyIds, $this->getBatchSize() ) as $propertyIdsChunk ) { |
|
80 | - foreach ( $propertyIdsChunk as $propertyIdSerialization ) { |
|
81 | - $this->output( sprintf( |
|
79 | + foreach (array_chunk($propertyIds, $this->getBatchSize()) as $propertyIdsChunk) { |
|
80 | + foreach ($propertyIdsChunk as $propertyIdSerialization) { |
|
81 | + $this->output(sprintf( |
|
82 | 82 | 'Importing constraint statements for % 6s... ', |
83 | 83 | $propertyIdSerialization ), |
84 | 84 | $propertyIdSerialization |
85 | 85 | ); |
86 | - $startTime = microtime( true ); |
|
87 | - $job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization ); |
|
86 | + $startTime = microtime(true); |
|
87 | + $job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization); |
|
88 | 88 | $job->run(); |
89 | - $endTime = microtime( true ); |
|
90 | - $millis = ( $endTime - $startTime ) * 1000; |
|
91 | - $this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization ); |
|
89 | + $endTime = microtime(true); |
|
90 | + $millis = ($endTime - $startTime) * 1000; |
|
91 | + $this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization); |
|
92 | 92 | } |
93 | 93 | |
94 | - $this->output( 'Waiting for replication... ', 'waitForReplication' ); |
|
95 | - $startTime = microtime( true ); |
|
94 | + $this->output('Waiting for replication... ', 'waitForReplication'); |
|
95 | + $startTime = microtime(true); |
|
96 | 96 | $this->lbFactory->waitForReplication(); |
97 | - $endTime = microtime( true ); |
|
98 | - $millis = ( $endTime - $startTime ) * 1000; |
|
99 | - $this->output( sprintf( 'done in % 6.2f ms.', $millis ), 'waitForReplication' ); |
|
97 | + $endTime = microtime(true); |
|
98 | + $millis = ($endTime - $startTime) * 1000; |
|
99 | + $this->output(sprintf('done in % 6.2f ms.', $millis), 'waitForReplication'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | private const BATCH_SIZE = 50; |
40 | 40 | |
41 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
42 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
41 | + public static function newFromGlobalState(Title $title, array $params) { |
|
42 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
43 | 43 | $services = MediaWikiServices::getInstance(); |
44 | 44 | $repo = WikibaseRepo::getDefaultInstance(); |
45 | 45 | return new UpdateConstraintsTableJob( |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $services->getMainConfig(), |
51 | 51 | ConstraintsServices::getConstraintStore(), |
52 | 52 | $services->getDBLoadBalancerFactory(), |
53 | - $repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
53 | + $repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
54 | 54 | $repo->getBaseDataModelSerializerFactory()->newSnakSerializer() |
55 | 55 | ); |
56 | 56 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | EntityRevisionLookup $entityRevisionLookup, |
111 | 111 | Serializer $snakSerializer |
112 | 112 | ) { |
113 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
113 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
114 | 114 | |
115 | 115 | $this->propertyId = $propertyId; |
116 | 116 | $this->revisionId = $revisionId; |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | $this->snakSerializer = $snakSerializer; |
122 | 122 | } |
123 | 123 | |
124 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
124 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
125 | 125 | $parameters = []; |
126 | - foreach ( $qualifiers as $qualifier ) { |
|
126 | + foreach ($qualifiers as $qualifier) { |
|
127 | 127 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
128 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
128 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
129 | 129 | $parameters[$qualifierId][] = $paramSerialization; |
130 | 130 | } |
131 | 131 | return $parameters; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | '@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue'; |
143 | 143 | $entityId = $dataValue->getEntityId(); |
144 | 144 | $constraintTypeQid = $entityId->getSerialization(); |
145 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
145 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
146 | 146 | return new Constraint( |
147 | 147 | $constraintId, |
148 | 148 | $propertyId, |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | PropertyId $propertyConstraintPropertyId |
158 | 158 | ) { |
159 | 159 | $constraintsStatements = $property->getStatements() |
160 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
161 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
160 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
161 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
162 | 162 | $constraints = []; |
163 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
164 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
165 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
166 | - $constraintStore->insertBatch( $constraints ); |
|
163 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
164 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
165 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
166 | + $constraintStore->insertBatch($constraints); |
|
167 | 167 | // interrupt transaction and wait for replication |
168 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
169 | - $connection->endAtomic( __CLASS__ ); |
|
170 | - if ( !$connection->explicitTrxActive() ) { |
|
168 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
169 | + $connection->endAtomic(__CLASS__); |
|
170 | + if (!$connection->explicitTrxActive()) { |
|
171 | 171 | $this->lbFactory->waitForReplication(); |
172 | 172 | } |
173 | - $connection->startAtomic( __CLASS__ ); |
|
173 | + $connection->startAtomic(__CLASS__); |
|
174 | 174 | $constraints = []; |
175 | 175 | } |
176 | 176 | } |
177 | - $constraintStore->insertBatch( $constraints ); |
|
177 | + $constraintStore->insertBatch($constraints); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -185,24 +185,24 @@ discard block |
||
185 | 185 | public function run() { |
186 | 186 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
187 | 187 | |
188 | - $propertyId = new PropertyId( $this->propertyId ); |
|
188 | + $propertyId = new PropertyId($this->propertyId); |
|
189 | 189 | $propertyRevision = $this->entityRevisionLookup->getEntityRevision( |
190 | 190 | $propertyId, |
191 | 191 | 0, // latest |
192 | 192 | LookupConstants::LATEST_FROM_REPLICA |
193 | 193 | ); |
194 | 194 | |
195 | - if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) { |
|
196 | - JobQueueGroup::singleton()->push( $this ); |
|
195 | + if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) { |
|
196 | + JobQueueGroup::singleton()->push($this); |
|
197 | 197 | return true; |
198 | 198 | } |
199 | 199 | |
200 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
200 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
201 | 201 | // start transaction (if not started yet) – using __CLASS__, not __METHOD__, |
202 | 202 | // because importConstraintsForProperty() can interrupt the transaction |
203 | - $connection->startAtomic( __CLASS__ ); |
|
203 | + $connection->startAtomic(__CLASS__); |
|
204 | 204 | |
205 | - $this->constraintStore->deleteForProperty( $propertyId ); |
|
205 | + $this->constraintStore->deleteForProperty($propertyId); |
|
206 | 206 | |
207 | 207 | /** @var Property $property */ |
208 | 208 | $property = $propertyRevision->getEntity(); |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | $this->importConstraintsForProperty( |
211 | 211 | $property, |
212 | 212 | $this->constraintStore, |
213 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
213 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
214 | 214 | ); |
215 | 215 | |
216 | - $connection->endAtomic( __CLASS__ ); |
|
216 | + $connection->endAtomic(__CLASS__); |
|
217 | 217 | |
218 | 218 | return true; |
219 | 219 | } |
@@ -28,46 +28,46 @@ discard block |
||
28 | 28 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
29 | 29 | |
30 | 30 | return [ |
31 | - ConstraintsServices::EXPIRY_LOCK => function ( MediaWikiServices $services ) { |
|
32 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
31 | + ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) { |
|
32 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
33 | 33 | }, |
34 | 34 | |
35 | - ConstraintsServices::LOGGING_HELPER => function ( MediaWikiServices $services ) { |
|
35 | + ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) { |
|
36 | 36 | return new LoggingHelper( |
37 | 37 | $services->getStatsdDataFactory(), |
38 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
38 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
39 | 39 | $services->getMainConfig() |
40 | 40 | ); |
41 | 41 | }, |
42 | 42 | |
43 | - ConstraintsServices::CONSTRAINT_STORE => function ( MediaWikiServices $services ) { |
|
43 | + ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) { |
|
44 | 44 | $wbRepo = WikibaseRepo::getDefaultInstance(); |
45 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
46 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
45 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
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 ) { |
|
60 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
61 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
59 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
60 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
61 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
62 | 62 | $dbName = $propertySource->getDatabaseName(); |
63 | 63 | $rawLookup = new ConstraintRepositoryLookup( |
64 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
64 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
65 | 65 | $dbName |
66 | 66 | ); |
67 | - return new CachingConstraintLookup( $rawLookup ); |
|
67 | + return new CachingConstraintLookup($rawLookup); |
|
68 | 68 | }, |
69 | 69 | |
70 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function ( MediaWikiServices $services ) { |
|
70 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
71 | 71 | return new CheckResultSerializer( |
72 | 72 | new ConstraintSerializer( |
73 | 73 | false // constraint parameters are not exposed |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | ); |
79 | 79 | }, |
80 | 80 | |
81 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function ( MediaWikiServices $services ) { |
|
81 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
82 | 82 | // TODO in the future, get DataValueFactory from $services? |
83 | 83 | $repo = WikibaseRepo::getDefaultInstance(); |
84 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
84 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
85 | 85 | $dataValueFactory = $repo->getDataValueFactory(); |
86 | 86 | |
87 | 87 | return new CheckResultDeserializer( |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | ); |
96 | 96 | }, |
97 | 97 | |
98 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function ( MediaWikiServices $services ) { |
|
98 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
99 | 99 | return new ViolationMessageSerializer(); |
100 | 100 | }, |
101 | 101 | |
102 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function ( MediaWikiServices $services ) { |
|
102 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
103 | 103 | // TODO in the future, get DataValueFactory from $services? |
104 | 104 | $repo = WikibaseRepo::getDefaultInstance(); |
105 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
105 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
106 | 106 | $dataValueFactory = $repo->getDataValueFactory(); |
107 | 107 | |
108 | 108 | return new ViolationMessageDeserializer( |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | ); |
112 | 112 | }, |
113 | 113 | |
114 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function ( MediaWikiServices $services ) { |
|
114 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
115 | 115 | // TODO in the future, get DeserializerFactory from $services? |
116 | 116 | $repo = WikibaseRepo::getDefaultInstance(); |
117 | 117 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
118 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
118 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
119 | 119 | |
120 | 120 | return new ConstraintParameterParser( |
121 | 121 | $services->getMainConfig(), |
122 | 122 | $deserializerFactory, |
123 | - $entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri() |
|
123 | + $entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri() |
|
124 | 124 | ); |
125 | 125 | }, |
126 | 126 | |
127 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
127 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
128 | 128 | return new ConnectionCheckerHelper(); |
129 | 129 | }, |
130 | 130 | |
131 | - ConstraintsServices::RANGE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
131 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
132 | 132 | // TODO in the future, get UnitConverter from $services? |
133 | 133 | $repo = WikibaseRepo::getDefaultInstance(); |
134 | 134 | $unitConverter = $repo->getUnitConverter(); |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | ); |
140 | 140 | }, |
141 | 141 | |
142 | - ConstraintsServices::SPARQL_HELPER => function ( MediaWikiServices $services ) { |
|
143 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
144 | - if ( $endpoint === '' ) { |
|
142 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
143 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
144 | + if ($endpoint === '') { |
|
145 | 145 | return new DummySparqlHelper(); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // TODO in the future, get RDFVocabulary and PropertyDataTypeLookup from $services? |
149 | 149 | $repo = WikibaseRepo::getDefaultInstance(); |
150 | 150 | $rdfVocabulary = $repo->getRdfVocabulary(); |
151 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
151 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
152 | 152 | $propertyDataTypeLookup = $repo->getPropertyDataTypeLookup(); |
153 | 153 | |
154 | 154 | return new SparqlHelper( |
@@ -157,121 +157,121 @@ discard block |
||
157 | 157 | $entityIdParser, |
158 | 158 | $propertyDataTypeLookup, |
159 | 159 | $services->getMainWANObjectCache(), |
160 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
161 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
160 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
161 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
162 | 162 | $services->getStatsdDataFactory(), |
163 | - ConstraintsServices::getExpiryLock( $services ), |
|
163 | + ConstraintsServices::getExpiryLock($services), |
|
164 | 164 | ConstraintsServices::getLoggingHelper(), |
165 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
165 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
166 | 166 | $services->getHttpRequestFactory() |
167 | 167 | ); |
168 | 168 | }, |
169 | 169 | |
170 | - ConstraintsServices::TYPE_CHECKER_HELPER => function ( MediaWikiServices $services ) { |
|
170 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
171 | 171 | return new TypeCheckerHelper( |
172 | - WikibaseServices::getEntityLookup( $services ), |
|
172 | + WikibaseServices::getEntityLookup($services), |
|
173 | 173 | $services->getMainConfig(), |
174 | - ConstraintsServices::getSparqlHelper( $services ), |
|
174 | + ConstraintsServices::getSparqlHelper($services), |
|
175 | 175 | $services->getStatsdDataFactory() |
176 | 176 | ); |
177 | 177 | }, |
178 | 178 | |
179 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function ( MediaWikiServices $services ) { |
|
180 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
179 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
180 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
181 | 181 | |
182 | 182 | $config = $services->getMainConfig(); |
183 | 183 | $checkerMap = [ |
184 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
185 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
186 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
187 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
188 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
189 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
190 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
191 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
192 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
193 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
194 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
195 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
196 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
197 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
198 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
199 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
200 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
201 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
202 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
203 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
204 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
205 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
206 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
207 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
208 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
209 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
210 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
211 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
212 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
213 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
214 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
215 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
216 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
217 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
218 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
219 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
220 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
221 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
222 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
223 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
224 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
225 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
226 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
227 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
228 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
229 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
230 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
231 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
232 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
233 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
234 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
235 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
236 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
237 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
238 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
239 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
240 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
241 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
184 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
185 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
186 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
187 | + => ConstraintCheckerServices::getItemChecker($services), |
|
188 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
189 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
190 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
191 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
192 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
193 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
194 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
195 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
196 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
197 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
198 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
199 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
200 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
201 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
202 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
203 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
204 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
205 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
206 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
207 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
208 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
209 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
210 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
211 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
212 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
213 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
214 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
215 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
216 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
217 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
218 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
219 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
220 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
221 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
222 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
223 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
224 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
225 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
226 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
227 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
228 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
229 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
230 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
231 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
232 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
233 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
234 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
235 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
236 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
237 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
238 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
239 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
240 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
241 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
242 | 242 | ]; |
243 | 243 | |
244 | 244 | return new DelegatingConstraintChecker( |
245 | - WikibaseServices::getEntityLookup( $services ), |
|
245 | + WikibaseServices::getEntityLookup($services), |
|
246 | 246 | $checkerMap, |
247 | - ConstraintsServices::getConstraintLookup( $services ), |
|
248 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
247 | + ConstraintsServices::getConstraintLookup($services), |
|
248 | + ConstraintsServices::getConstraintParameterParser($services), |
|
249 | 249 | $statementGuidParser, |
250 | - ConstraintsServices::getLoggingHelper( $services ), |
|
251 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
252 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
253 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
250 | + ConstraintsServices::getLoggingHelper($services), |
|
251 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
252 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
253 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
254 | 254 | ); |
255 | 255 | }, |
256 | 256 | |
257 | - ConstraintsServices::RESULTS_SOURCE => function ( MediaWikiServices $services ) { |
|
257 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
258 | 258 | $config = $services->getMainConfig(); |
259 | 259 | $resultsSource = new CheckingResultsSource( |
260 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
260 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
261 | 261 | ); |
262 | 262 | |
263 | 263 | $cacheCheckConstraintsResults = false; |
264 | 264 | |
265 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
265 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
266 | 266 | $cacheCheckConstraintsResults = true; |
267 | 267 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
268 | 268 | // TODO we should always be able to cache constraint check results (T244726) |
269 | 269 | $repo = WikibaseRepo::getDefaultInstance(); |
270 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
271 | - foreach ( $entitySources as $entitySource ) { |
|
272 | - if ( $entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName() ) { |
|
273 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
274 | - 'Cannot cache constraint check results for non-local source: ' . |
|
270 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
271 | + foreach ($entitySources as $entitySource) { |
|
272 | + if ($entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName()) { |
|
273 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
274 | + 'Cannot cache constraint check results for non-local source: '. |
|
275 | 275 | $entitySource->getSourceName() |
276 | 276 | ); |
277 | 277 | $cacheCheckConstraintsResults = false; |
@@ -280,29 +280,29 @@ discard block |
||
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - if ( $cacheCheckConstraintsResults ) { |
|
283 | + if ($cacheCheckConstraintsResults) { |
|
284 | 284 | $possiblyStaleConstraintTypes = [ |
285 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
286 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
287 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
288 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
285 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
286 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
287 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
288 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
289 | 289 | ]; |
290 | 290 | // TODO in the future, get WikiPageEntityMetaDataAccessor from $services? |
291 | 291 | $repo = WikibaseRepo::getDefaultInstance(); |
292 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
292 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
293 | 293 | $wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor(); |
294 | 294 | |
295 | 295 | $resultsSource = new CachingResultsSource( |
296 | 296 | $resultsSource, |
297 | 297 | ResultsCache::getDefaultInstance(), |
298 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
299 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
298 | + ConstraintsServices::getCheckResultSerializer($services), |
|
299 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
300 | 300 | $wikiPageEntityMetaDataAccessor, |
301 | 301 | $entityIdParser, |
302 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
302 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
303 | 303 | $possiblyStaleConstraintTypes, |
304 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
305 | - ConstraintsServices::getLoggingHelper( $services ) |
|
304 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
305 | + ConstraintsServices::getLoggingHelper($services) |
|
306 | 306 | ); |
307 | 307 | } |
308 | 308 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param WANObjectCache $cache |
37 | 37 | * @param string $formatVersion The version of the API response format. |
38 | 38 | */ |
39 | - public function __construct( WANObjectCache $cache, $formatVersion ) { |
|
39 | + public function __construct(WANObjectCache $cache, $formatVersion) { |
|
40 | 40 | $this->cache = $cache; |
41 | 41 | $this->formatVersion = $formatVersion; |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param EntityId $entityId |
46 | 46 | * @return string cache key |
47 | 47 | */ |
48 | - public function makeKey( EntityId $entityId ) { |
|
48 | + public function makeKey(EntityId $entityId) { |
|
49 | 49 | return $this->cache->makeKey( |
50 | 50 | 'WikibaseQualityConstraints', // extension |
51 | 51 | 'checkConstraints', // action |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param mixed|null &$info |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$info = null ) { |
|
65 | - return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $info ); |
|
64 | + public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$info = null) { |
|
65 | + return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $info); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | * @param array $opts |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) { |
|
76 | - return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts ); |
|
75 | + public function set(EntityId $key, $value, $ttl = 0, array $opts = []) { |
|
76 | + return $this->cache->set($this->makeKey($key), $value, $ttl, $opts); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @param EntityId $key |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - public function delete( EntityId $key ) { |
|
84 | - return $this->cache->delete( $this->makeKey( $key ) ); |
|
83 | + public function delete(EntityId $key) { |
|
84 | + return $this->cache->delete($this->makeKey($key)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |