@@ -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 | return new UpdateConstraintsTableJob( |
45 | 45 | $title, |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | $services->getMainConfig(), |
50 | 50 | ConstraintsServices::getConstraintStore(), |
51 | 51 | $services->getDBLoadBalancerFactory(), |
52 | - WikibaseRepo::getStore()->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
53 | - WikibaseRepo::getBaseDataModelSerializerFactory( $services ) |
|
52 | + WikibaseRepo::getStore()->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
53 | + WikibaseRepo::getBaseDataModelSerializerFactory($services) |
|
54 | 54 | ->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 | } |