@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | use Wikibase\Repo\WikibaseRepo; |
16 | 16 | |
17 | 17 | // @codeCoverageIgnoreStart |
18 | -$basePath = getenv( "MW_INSTALL_PATH" ) !== false |
|
19 | - ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../.."; |
|
18 | +$basePath = getenv("MW_INSTALL_PATH") !== false |
|
19 | + ? getenv("MW_INSTALL_PATH") : __DIR__."/../../.."; |
|
20 | 20 | |
21 | -require_once $basePath . "/maintenance/Maintenance.php"; |
|
21 | +require_once $basePath."/maintenance/Maintenance.php"; |
|
22 | 22 | // @codeCoverageIgnoreEnd |
23 | 23 | |
24 | 24 | /** |
@@ -52,20 +52,20 @@ discard block |
||
52 | 52 | parent::__construct(); |
53 | 53 | |
54 | 54 | $this->addDescription( |
55 | - 'Import entities needed for constraint checks ' . |
|
55 | + 'Import entities needed for constraint checks '. |
|
56 | 56 | 'from Wikidata into the local repository.' |
57 | 57 | ); |
58 | 58 | $this->addOption( |
59 | 59 | 'config-format', |
60 | - 'The format in which the resulting configuration will be omitted: ' . |
|
61 | - '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' . |
|
60 | + 'The format in which the resulting configuration will be omitted: '. |
|
61 | + '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '. |
|
62 | 62 | 'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.' |
63 | 63 | ); |
64 | 64 | $this->addOption( |
65 | 65 | 'dry-run', |
66 | 66 | 'Don’t actually import entities, just print which ones would be imported.' |
67 | 67 | ); |
68 | - $this->requireExtension( 'WikibaseQualityConstraints' ); |
|
68 | + $this->requireExtension('WikibaseQualityConstraints'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $this->entitySerializer = $repo->getAllTypesEntitySerializer(); |
77 | 77 | $this->entityDeserializer = $repo->getInternalFormatEntityDeserializer(); |
78 | 78 | $this->entityStore = $repo->getEntityStore(); |
79 | - if ( !$this->getOption( 'dry-run', false ) ) { |
|
80 | - $this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' ); |
|
79 | + if (!$this->getOption('dry-run', false)) { |
|
80 | + $this->user = User::newSystemUser('WikibaseQualityConstraints importer'); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -86,21 +86,21 @@ discard block |
||
86 | 86 | |
87 | 87 | $configUpdates = []; |
88 | 88 | |
89 | - $extensionJsonFile = __DIR__ . '/../extension.json'; |
|
90 | - $extensionJsonText = file_get_contents( $extensionJsonFile ); |
|
91 | - $extensionJson = json_decode( $extensionJsonText, /* assoc = */ true ); |
|
89 | + $extensionJsonFile = __DIR__.'/../extension.json'; |
|
90 | + $extensionJsonText = file_get_contents($extensionJsonFile); |
|
91 | + $extensionJson = json_decode($extensionJsonText, /* assoc = */ true); |
|
92 | 92 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
93 | - $wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() ); |
|
93 | + $wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig()); |
|
94 | 94 | |
95 | - foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) { |
|
96 | - $localEntityId = $this->importEntityFromWikidata( $wikidataEntityId ); |
|
95 | + foreach ($wikidataEntityIds as $key => $wikidataEntityId) { |
|
96 | + $localEntityId = $this->importEntityFromWikidata($wikidataEntityId); |
|
97 | 97 | $configUpdates[$key] = [ |
98 | 98 | 'wikidata' => $wikidataEntityId, |
99 | 99 | 'local' => $localEntityId, |
100 | 100 | ]; |
101 | 101 | } |
102 | 102 | |
103 | - $this->outputConfigUpdates( $configUpdates ); |
|
103 | + $this->outputConfigUpdates($configUpdates); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | * @param Config $wikiConfig |
109 | 109 | * @return string[] |
110 | 110 | */ |
111 | - private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) { |
|
111 | + private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) { |
|
112 | 112 | $wikidataEntityIds = []; |
113 | 113 | |
114 | - foreach ( $extensionJsonConfig as $key => $value ) { |
|
115 | - if ( !preg_match( '/Id$/', $key ) ) { |
|
114 | + foreach ($extensionJsonConfig as $key => $value) { |
|
115 | + if (!preg_match('/Id$/', $key)) { |
|
116 | 116 | continue; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $wikidataEntityId = $value['value']; |
120 | - $localEntityId = $wikiConfig->get( $key ); |
|
120 | + $localEntityId = $wikiConfig->get($key); |
|
121 | 121 | |
122 | - if ( $localEntityId === $wikidataEntityId ) { |
|
122 | + if ($localEntityId === $wikidataEntityId) { |
|
123 | 123 | $wikidataEntityIds[$key] = $wikidataEntityId; |
124 | 124 | } |
125 | 125 | } |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | * @param string $wikidataEntityId |
132 | 132 | * @return string local entity ID |
133 | 133 | */ |
134 | - private function importEntityFromWikidata( $wikidataEntityId ) { |
|
134 | + private function importEntityFromWikidata($wikidataEntityId) { |
|
135 | 135 | $wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json"; |
136 | - $wikidataEntitiesJson = file_get_contents( $wikidataEntityUrl ); |
|
137 | - return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ); |
|
136 | + $wikidataEntitiesJson = file_get_contents($wikidataEntityUrl); |
|
137 | + return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,24 +142,24 @@ discard block |
||
142 | 142 | * @param string $wikidataEntitiesJson |
143 | 143 | * @return string local entity ID |
144 | 144 | */ |
145 | - private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) { |
|
145 | + private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) { |
|
146 | 146 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
147 | - $wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId]; |
|
148 | - $wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray ); |
|
147 | + $wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId]; |
|
148 | + $wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray); |
|
149 | 149 | |
150 | - $wikidataEntity->setId( null ); |
|
150 | + $wikidataEntity->setId(null); |
|
151 | 151 | |
152 | - if ( $wikidataEntity instanceof StatementListProvider ) { |
|
152 | + if ($wikidataEntity instanceof StatementListProvider) { |
|
153 | 153 | $wikidataEntity->getStatements()->clear(); |
154 | 154 | } |
155 | 155 | |
156 | - if ( $wikidataEntity instanceof Item ) { |
|
157 | - $wikidataEntity->setSiteLinkList( new SiteLinkList() ); |
|
156 | + if ($wikidataEntity instanceof Item) { |
|
157 | + $wikidataEntity->setSiteLinkList(new SiteLinkList()); |
|
158 | 158 | } |
159 | 159 | |
160 | - if ( $this->getOption( 'dry-run', false ) ) { |
|
161 | - $wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) ); |
|
162 | - $this->output( $wikidataEntityJson . "\n" ); |
|
160 | + if ($this->getOption('dry-run', false)) { |
|
161 | + $wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity)); |
|
162 | + $this->output($wikidataEntityJson."\n"); |
|
163 | 163 | return "-$wikidataEntityId"; |
164 | 164 | } |
165 | 165 | |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | )->getEntity(); |
173 | 173 | |
174 | 174 | return $localEntity->getId()->getSerialization(); |
175 | - } catch ( StorageException $storageException ) { |
|
176 | - return $this->storageExceptionToEntityId( $storageException ); |
|
175 | + } catch (StorageException $storageException) { |
|
176 | + return $this->storageExceptionToEntityId($storageException); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - private function storageExceptionToEntityId( StorageException $storageException ) { |
|
180 | + private function storageExceptionToEntityId(StorageException $storageException) { |
|
181 | 181 | $message = $storageException->getMessage(); |
182 | 182 | // example messages: |
183 | 183 | // * Item [[Item:Q475|Q475]] already has label "as references" |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | // * Property [[Property:P694|P694]] already has label "instance of" |
188 | 188 | // associated with language code en. |
189 | 189 | $pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/'; |
190 | - if ( preg_match( $pattern, $message, $matches ) ) { |
|
190 | + if (preg_match($pattern, $message, $matches)) { |
|
191 | 191 | return $matches[1]; |
192 | 192 | } else { |
193 | 193 | throw $storageException; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - private function outputConfigUpdates( array $configUpdates ) { |
|
198 | - $configFormat = $this->getOption( 'config-format', 'globals' ); |
|
199 | - switch ( $configFormat ) { |
|
197 | + private function outputConfigUpdates(array $configUpdates) { |
|
198 | + $configFormat = $this->getOption('config-format', 'globals'); |
|
199 | + switch ($configFormat) { |
|
200 | 200 | case 'globals': |
201 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
201 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
202 | 202 | break; |
203 | 203 | case 'wgConf': |
204 | - $this->outputConfigUpdatesWgConf( $configUpdates ); |
|
204 | + $this->outputConfigUpdatesWgConf($configUpdates); |
|
205 | 205 | break; |
206 | 206 | default: |
207 | - $this->error( "Invalid config format \"$configFormat\", using \"globals\"" ); |
|
208 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
207 | + $this->error("Invalid config format \"$configFormat\", using \"globals\""); |
|
208 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
209 | 209 | break; |
210 | 210 | } |
211 | 211 | } |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @param array[] $configUpdates |
215 | 215 | */ |
216 | - private function outputConfigUpdatesGlobals( array $configUpdates ) { |
|
217 | - foreach ( $configUpdates as $key => $value ) { |
|
218 | - $localValueCode = var_export( $value['local'], true ); |
|
219 | - $this->output( "\$wg$key = $localValueCode;\n" ); |
|
216 | + private function outputConfigUpdatesGlobals(array $configUpdates) { |
|
217 | + foreach ($configUpdates as $key => $value) { |
|
218 | + $localValueCode = var_export($value['local'], true); |
|
219 | + $this->output("\$wg$key = $localValueCode;\n"); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | 224 | * @param array[] $configUpdates |
225 | 225 | */ |
226 | - private function outputConfigUpdatesWgConf( array $configUpdates ) { |
|
227 | - foreach ( $configUpdates as $key => $value ) { |
|
228 | - $keyCode = var_export( "wg$key", true ); |
|
229 | - $wikidataValueCode = var_export( $value['wikidata'], true ); |
|
230 | - $localValueCode = var_export( $value['local'], true ); |
|
231 | - $wikiIdCode = var_export( wfWikiID(), true ); |
|
226 | + private function outputConfigUpdatesWgConf(array $configUpdates) { |
|
227 | + foreach ($configUpdates as $key => $value) { |
|
228 | + $keyCode = var_export("wg$key", true); |
|
229 | + $wikidataValueCode = var_export($value['wikidata'], true); |
|
230 | + $localValueCode = var_export($value['local'], true); |
|
231 | + $wikiIdCode = var_export(wfWikiID(), true); |
|
232 | 232 | $block = <<< EOF |
233 | 233 | $keyCode => [ |
234 | 234 | 'default' => $wikidataValueCode, |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | |
239 | 239 | EOF; |
240 | - $this->output( $block ); |
|
240 | + $this->output($block); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param ItemId $itemId |
45 | 45 | * @return self |
46 | 46 | */ |
47 | - public static function fromItemId( ItemId $itemId ) { |
|
47 | + public static function fromItemId(ItemId $itemId) { |
|
48 | 48 | $ret = new self; |
49 | 49 | $ret->itemId = $itemId; |
50 | 50 | return $ret; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * @throws InvalidArgumentException |
81 | 81 | * @return self |
82 | 82 | */ |
83 | - public static function fromSnak( Snak $snak ) { |
|
84 | - switch ( true ) { |
|
83 | + public static function fromSnak(Snak $snak) { |
|
84 | + switch (true) { |
|
85 | 85 | case $snak instanceof PropertyValueSnak: |
86 | 86 | $dataValue = $snak->getDataValue(); |
87 | - if ( $dataValue instanceof EntityIdValue ) { |
|
87 | + if ($dataValue instanceof EntityIdValue) { |
|
88 | 88 | $itemId = $dataValue->getEntityId(); |
89 | - if ( $itemId instanceof ItemId ) { |
|
90 | - return self::fromItemId( $itemId ); |
|
89 | + if ($itemId instanceof ItemId) { |
|
90 | + return self::fromItemId($itemId); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | break; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return self::noValue(); |
98 | 98 | } |
99 | 99 | |
100 | - throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' ); |
|
100 | + throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @return ItemId |
136 | 136 | */ |
137 | 137 | public function getItemId() { |
138 | - if ( !$this->isValue() ) { |
|
139 | - throw new DomainException( 'This value does not contain an item ID.' ); |
|
138 | + if (!$this->isValue()) { |
|
139 | + throw new DomainException('This value does not contain an item ID.'); |
|
140 | 140 | } |
141 | 141 | return $this->itemId; |
142 | 142 | } |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | * @param Snak $snak |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function matchesSnak( Snak $snak ) { |
|
152 | - switch ( true ) { |
|
151 | + public function matchesSnak(Snak $snak) { |
|
152 | + switch (true) { |
|
153 | 153 | case $snak instanceof PropertyValueSnak: |
154 | 154 | $dataValue = $snak->getDataValue(); |
155 | 155 | return $this->isValue() && |
156 | 156 | $dataValue instanceof EntityIdValue && |
157 | 157 | $dataValue->getEntityId() instanceof ItemId && |
158 | - $dataValue->getEntityId()->equals( $this->getItemId() ); |
|
158 | + $dataValue->getEntityId()->equals($this->getItemId()); |
|
159 | 159 | case $snak instanceof PropertySomeValueSnak: |
160 | 160 | return $this->isSomeValue(); |
161 | 161 | case $snak instanceof PropertyNoValueSnak: |
@@ -37,25 +37,25 @@ discard block |
||
37 | 37 | * @param Title $title |
38 | 38 | * @param string[] $params should contain 'entityId' => 'Q1234' |
39 | 39 | */ |
40 | - public function __construct( Title $title, array $params ) { |
|
41 | - parent::__construct( self::COMMAND, $title, $params ); |
|
40 | + public function __construct(Title $title, array $params) { |
|
41 | + parent::__construct(self::COMMAND, $title, $params); |
|
42 | 42 | $this->removeDuplicates = true; |
43 | 43 | |
44 | - Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' ); |
|
44 | + Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']'); |
|
45 | 45 | |
46 | - $resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() ); |
|
46 | + $resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance()); |
|
47 | 47 | '@phan-var CachingResultsSource $resultSource'; |
48 | 48 | // This job should only ever be used when caching result sources are used. |
49 | - $this->setResultsSource( $resultSource ); |
|
49 | + $this->setResultsSource($resultSource); |
|
50 | 50 | |
51 | - $this->setEntityIdParser( WikibaseRepo::getDefaultInstance()->getEntityIdParser() ); |
|
51 | + $this->setEntityIdParser(WikibaseRepo::getDefaultInstance()->getEntityIdParser()); |
|
52 | 52 | } |
53 | 53 | |
54 | - public function setResultsSource( CachingResultsSource $resultsSource ) { |
|
54 | + public function setResultsSource(CachingResultsSource $resultsSource) { |
|
55 | 55 | $this->resultsSource = $resultsSource; |
56 | 56 | } |
57 | 57 | |
58 | - public function setEntityIdParser( EntityIdParser $parser ) { |
|
58 | + public function setEntityIdParser(EntityIdParser $parser) { |
|
59 | 59 | $this->entityIdParser = $parser; |
60 | 60 | } |
61 | 61 | |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function run() { |
68 | 68 | try { |
69 | - $entityId = $this->entityIdParser->parse( $this->params['entityId'] ); |
|
70 | - } catch ( EntityIdParsingException $e ) { |
|
69 | + $entityId = $this->entityIdParser->parse($this->params['entityId']); |
|
70 | + } catch (EntityIdParsingException $e) { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | |
74 | - $this->checkConstraints( $entityId ); |
|
74 | + $this->checkConstraints($entityId); |
|
75 | 75 | |
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | |
79 | - private function checkConstraints( EntityId $entityId ) { |
|
79 | + private function checkConstraints(EntityId $entityId) { |
|
80 | 80 | $this->resultsSource->getResults( |
81 | - [ $entityId ], |
|
81 | + [$entityId], |
|
82 | 82 | [], |
83 | 83 | null, |
84 | 84 | [] |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | const BATCH_SIZE = 10; |
30 | 30 | |
31 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
32 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
31 | + public static function newFromGlobalState(Title $title, array $params) { |
|
32 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
33 | 33 | $repo = WikibaseRepo::getDefaultInstance(); |
34 | 34 | return new UpdateConstraintsTableJob( |
35 | 35 | $title, |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $params['revisionId'] ?? null, |
39 | 39 | MediaWikiServices::getInstance()->getMainConfig(), |
40 | 40 | ConstraintsServices::getConstraintRepository(), |
41 | - $repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
41 | + $repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
42 | 42 | $repo->getBaseDataModelSerializerFactory()->newSnakSerializer() |
43 | 43 | ); |
44 | 44 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | EntityRevisionLookup $entityRevisionLookup, |
94 | 94 | Serializer $snakSerializer |
95 | 95 | ) { |
96 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
96 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
97 | 97 | |
98 | 98 | $this->propertyId = $propertyId; |
99 | 99 | $this->revisionId = $revisionId; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | $this->snakSerializer = $snakSerializer; |
104 | 104 | } |
105 | 105 | |
106 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
106 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
107 | 107 | $parameters = []; |
108 | - foreach ( $qualifiers as $qualifier ) { |
|
108 | + foreach ($qualifiers as $qualifier) { |
|
109 | 109 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
110 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
110 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
111 | 111 | $parameters[$qualifierId][] = $paramSerialization; |
112 | 112 | } |
113 | 113 | return $parameters; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | '@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue'; |
125 | 125 | $entityId = $dataValue->getEntityId(); |
126 | 126 | $constraintTypeQid = $entityId->getSerialization(); |
127 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
127 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
128 | 128 | return new Constraint( |
129 | 129 | $constraintId, |
130 | 130 | $propertyId, |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | PropertyId $propertyConstraintPropertyId |
140 | 140 | ) { |
141 | 141 | $constraintsStatements = $property->getStatements() |
142 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
143 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
142 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
143 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
144 | 144 | $constraints = []; |
145 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
146 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
147 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
148 | - $constraintRepo->insertBatch( $constraints ); |
|
145 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
146 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
147 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
148 | + $constraintRepo->insertBatch($constraints); |
|
149 | 149 | $constraints = []; |
150 | 150 | } |
151 | 151 | } |
152 | - $constraintRepo->insertBatch( $constraints ); |
|
152 | + $constraintRepo->insertBatch($constraints); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,19 +160,19 @@ discard block |
||
160 | 160 | public function run() { |
161 | 161 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
162 | 162 | |
163 | - $propertyId = new PropertyId( $this->propertyId ); |
|
163 | + $propertyId = new PropertyId($this->propertyId); |
|
164 | 164 | $propertyRevision = $this->entityRevisionLookup->getEntityRevision( |
165 | 165 | $propertyId, |
166 | 166 | 0, // latest |
167 | 167 | EntityRevisionLookup::LATEST_FROM_REPLICA |
168 | 168 | ); |
169 | 169 | |
170 | - if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) { |
|
171 | - JobQueueGroup::singleton()->push( $this ); |
|
170 | + if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) { |
|
171 | + JobQueueGroup::singleton()->push($this); |
|
172 | 172 | return true; |
173 | 173 | } |
174 | 174 | |
175 | - $this->constraintRepo->deleteForProperty( $propertyId ); |
|
175 | + $this->constraintRepo->deleteForProperty($propertyId); |
|
176 | 176 | |
177 | 177 | /** @var Property $property */ |
178 | 178 | $property = $propertyRevision->getEntity(); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $this->importConstraintsForProperty( |
181 | 181 | $property, |
182 | 182 | $this->constraintRepo, |
183 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
183 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
184 | 184 | ); |
185 | 185 | |
186 | 186 | return true; |