@@ -20,47 +20,47 @@ |
||
| 20 | 20 | { |
| 21 | 21 | |
| 22 | 22 | /** @inheritDoc */ |
| 23 | - public function onArticlePurge( $wikiPage ) { |
|
| 23 | + public function onArticlePurge($wikiPage) { |
|
| 24 | 24 | $entityContentFactory = WikibaseRepo::getEntityContentFactory(); |
| 25 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
| 25 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
| 26 | 26 | $entityIdLookup = WikibaseRepo::getEntityIdLookup(); |
| 27 | - $entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
| 28 | - if ( $entityId !== null ) { |
|
| 27 | + $entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle()); |
|
| 28 | + if ($entityId !== null) { |
|
| 29 | 29 | $resultsCache = ResultsCache::getDefaultInstance(); |
| 30 | - $resultsCache->delete( $entityId ); |
|
| 30 | + $resultsCache->delete($entityId); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** @inheritDoc */ |
| 36 | - public function onBeforePageDisplay( $out, $skin ): void { |
|
| 36 | + public function onBeforePageDisplay($out, $skin): void { |
|
| 37 | 37 | $lookup = WikibaseRepo::getEntityNamespaceLookup(); |
| 38 | 38 | $title = $out->getTitle(); |
| 39 | - if ( $title === null ) { |
|
| 39 | + if ($title === null) { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) { |
|
| 43 | + if (!$lookup->isNamespaceWithEntities($title->getNamespace())) { |
|
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
| 46 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $services = MediaWikiServices::getInstance(); |
| 51 | 51 | $config = $services->getMainConfig(); |
| 52 | 52 | |
| 53 | - $isMobileView = ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) && |
|
| 54 | - $services->getService( 'MobileFrontend.Context' )->shouldDisplayMobileView(); |
|
| 55 | - if ( $isMobileView ) { |
|
| 53 | + $isMobileView = ExtensionRegistry::getInstance()->isLoaded('MobileFrontend') && |
|
| 54 | + $services->getService('MobileFrontend.Context')->shouldDisplayMobileView(); |
|
| 55 | + if ($isMobileView) { |
|
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
| 59 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
| 60 | 60 | |
| 61 | - if ( $config->get( 'WBQualityConstraintsShowConstraintViolationToNonLoggedInUsers' ) |
|
| 62 | - || $out->getUser()->isRegistered() ) { |
|
| 63 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
| 61 | + if ($config->get('WBQualityConstraintsShowConstraintViolationToNonLoggedInUsers') |
|
| 62 | + || $out->getUser()->isRegistered()) { |
|
| 63 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WikibaseQuality\ConstraintReport; |
| 6 | 6 | |
@@ -33,55 +33,55 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** @inheritDoc */ |
| 36 | - public function onWikibaseChangeNotification( Change $change ): void { |
|
| 37 | - if ( !( $change instanceof EntityChange ) ) { |
|
| 36 | + public function onWikibaseChangeNotification(Change $change): void { |
|
| 37 | + if (!($change instanceof EntityChange)) { |
|
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | /** @var EntityChange $change */ |
| 41 | 41 | |
| 42 | 42 | // If jobs are enabled and the results would be stored in some way run a job. |
| 43 | 43 | if ( |
| 44 | - $this->config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) && |
|
| 45 | - $this->config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) && |
|
| 44 | + $this->config->get('WBQualityConstraintsEnableConstraintsCheckJobs') && |
|
| 45 | + $this->config->get('WBQualityConstraintsCacheCheckConstraintsResults') && |
|
| 46 | 46 | $this->isSelectedForJobRunBasedOnPercentage() |
| 47 | 47 | ) { |
| 48 | - $params = [ 'entityId' => $change->getEntityId()->getSerialization() ]; |
|
| 48 | + $params = ['entityId' => $change->getEntityId()->getSerialization()]; |
|
| 49 | 49 | $this->jobQueueGroup->lazyPush( |
| 50 | - new JobSpecification( CheckConstraintsJob::COMMAND, $params ) |
|
| 50 | + new JobSpecification(CheckConstraintsJob::COMMAND, $params) |
|
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ( $this->config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
| 55 | - $this->isConstraintStatementsChange( $change ) |
|
| 54 | + if ($this->config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
| 55 | + $this->isConstraintStatementsChange($change) |
|
| 56 | 56 | ) { |
| 57 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
| 57 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
| 58 | 58 | $metadata = $change->getMetadata(); |
| 59 | - if ( array_key_exists( 'rev_id', $metadata ) ) { |
|
| 59 | + if (array_key_exists('rev_id', $metadata)) { |
|
| 60 | 60 | $params['revisionId'] = $metadata['rev_id']; |
| 61 | 61 | } |
| 62 | 62 | $this->jobQueueGroup->push( |
| 63 | - new JobSpecification( 'constraintsTableUpdate', $params ) |
|
| 63 | + new JobSpecification('constraintsTableUpdate', $params) |
|
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private function isSelectedForJobRunBasedOnPercentage(): bool { |
| 69 | - $percentage = $this->config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' ); |
|
| 69 | + $percentage = $this->config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio'); |
|
| 70 | 70 | |
| 71 | - return mt_rand( 1, 100 ) <= $percentage; |
|
| 71 | + return mt_rand(1, 100) <= $percentage; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - private function isConstraintStatementsChange( Change $change ): bool { |
|
| 75 | - if ( !( $change instanceof EntityChange ) || |
|
| 74 | + private function isConstraintStatementsChange(Change $change): bool { |
|
| 75 | + if (!($change instanceof EntityChange) || |
|
| 76 | 76 | $change->getAction() !== EntityChange::UPDATE || |
| 77 | - !( $change->getEntityId() instanceof NumericPropertyId ) |
|
| 77 | + !($change->getEntityId() instanceof NumericPropertyId) |
|
| 78 | 78 | ) { |
| 79 | 79 | return false; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $info = $change->getInfo(); |
| 83 | 83 | |
| 84 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
| 84 | + if (!array_key_exists('compactDiff', $info)) { |
|
| 85 | 85 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
| 86 | 86 | // so we only know that the change *might* affect the constraint statements |
| 87 | 87 | return true; |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | /** @var EntityDiffChangedAspects $aspects */ |
| 91 | 91 | $aspects = $info['compactDiff']; |
| 92 | 92 | |
| 93 | - $propertyConstraintId = $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
| 94 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
| 93 | + $propertyConstraintId = $this->config->get('WBQualityConstraintsPropertyConstraintId'); |
|
| 94 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | } |