@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | BeforePageDisplayHook |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - public static function onWikibaseChange( Change $change ) { |
|
| 30 | - if ( !( $change instanceof EntityChange ) ) { |
|
| 29 | + public static function onWikibaseChange(Change $change) { |
|
| 30 | + if (!($change instanceof EntityChange)) { |
|
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | 33 | /** @var EntityChange $change */ |
@@ -38,48 +38,48 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | // If jobs are enabled and the results would be stored in some way run a job. |
| 40 | 40 | if ( |
| 41 | - $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) && |
|
| 42 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) && |
|
| 41 | + $config->get('WBQualityConstraintsEnableConstraintsCheckJobs') && |
|
| 42 | + $config->get('WBQualityConstraintsCacheCheckConstraintsResults') && |
|
| 43 | 43 | self::isSelectedForJobRunBasedOnPercentage() |
| 44 | 44 | ) { |
| 45 | - $params = [ 'entityId' => $change->getEntityId()->getSerialization() ]; |
|
| 45 | + $params = ['entityId' => $change->getEntityId()->getSerialization()]; |
|
| 46 | 46 | $jobQueueGroup->lazyPush( |
| 47 | - new JobSpecification( CheckConstraintsJob::COMMAND, $params ) |
|
| 47 | + new JobSpecification(CheckConstraintsJob::COMMAND, $params) |
|
| 48 | 48 | ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
| 52 | - self::isConstraintStatementsChange( $config, $change ) |
|
| 51 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
| 52 | + self::isConstraintStatementsChange($config, $change) |
|
| 53 | 53 | ) { |
| 54 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
| 54 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
| 55 | 55 | $metadata = $change->getMetadata(); |
| 56 | - if ( array_key_exists( 'rev_id', $metadata ) ) { |
|
| 56 | + if (array_key_exists('rev_id', $metadata)) { |
|
| 57 | 57 | $params['revisionId'] = $metadata['rev_id']; |
| 58 | 58 | } |
| 59 | 59 | $jobQueueGroup->push( |
| 60 | - new JobSpecification( 'constraintsTableUpdate', $params ) |
|
| 60 | + new JobSpecification('constraintsTableUpdate', $params) |
|
| 61 | 61 | ); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | private static function isSelectedForJobRunBasedOnPercentage() { |
| 66 | 66 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
| 67 | - $percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' ); |
|
| 67 | + $percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio'); |
|
| 68 | 68 | |
| 69 | - return mt_rand( 1, 100 ) <= $percentage; |
|
| 69 | + return mt_rand(1, 100) <= $percentage; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
| 73 | - if ( !( $change instanceof EntityChange ) || |
|
| 72 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
| 73 | + if (!($change instanceof EntityChange) || |
|
| 74 | 74 | $change->getAction() !== EntityChange::UPDATE || |
| 75 | - !( $change->getEntityId() instanceof NumericPropertyId ) |
|
| 75 | + !($change->getEntityId() instanceof NumericPropertyId) |
|
| 76 | 76 | ) { |
| 77 | 77 | return false; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $info = $change->getInfo(); |
| 81 | 81 | |
| 82 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
| 82 | + if (!array_key_exists('compactDiff', $info)) { |
|
| 83 | 83 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
| 84 | 84 | // so we only know that the change *might* affect the constraint statements |
| 85 | 85 | return true; |
@@ -88,50 +88,50 @@ discard block |
||
| 88 | 88 | /** @var EntityDiffChangedAspects $aspects */ |
| 89 | 89 | $aspects = $info['compactDiff']; |
| 90 | 90 | |
| 91 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
| 92 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
| 91 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
| 92 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function onArticlePurge( $wikiPage ) { |
|
| 95 | + public function onArticlePurge($wikiPage) { |
|
| 96 | 96 | $entityContentFactory = WikibaseRepo::getEntityContentFactory(); |
| 97 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
| 97 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
| 98 | 98 | $entityIdLookup = WikibaseRepo::getEntityIdLookup(); |
| 99 | - $entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
| 100 | - if ( $entityId !== null ) { |
|
| 99 | + $entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle()); |
|
| 100 | + if ($entityId !== null) { |
|
| 101 | 101 | $resultsCache = ResultsCache::getDefaultInstance(); |
| 102 | - $resultsCache->delete( $entityId ); |
|
| 102 | + $resultsCache->delete($entityId); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function onBeforePageDisplay( $out, $skin ): void { |
|
| 107 | + public function onBeforePageDisplay($out, $skin): void { |
|
| 108 | 108 | $lookup = WikibaseRepo::getEntityNamespaceLookup(); |
| 109 | 109 | $title = $out->getTitle(); |
| 110 | - if ( $title === null ) { |
|
| 110 | + if ($title === null) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) { |
|
| 114 | + if (!$lookup->isNamespaceWithEntities($title->getNamespace())) { |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
| 117 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $services = MediaWikiServices::getInstance(); |
| 122 | 122 | $config = $services->getMainConfig(); |
| 123 | 123 | |
| 124 | - $isMobileView = ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) && |
|
| 125 | - $services->getService( 'MobileFrontend.Context' )->shouldDisplayMobileView(); |
|
| 126 | - if ( $isMobileView ) { |
|
| 124 | + $isMobileView = ExtensionRegistry::getInstance()->isLoaded('MobileFrontend') && |
|
| 125 | + $services->getService('MobileFrontend.Context')->shouldDisplayMobileView(); |
|
| 126 | + if ($isMobileView) { |
|
| 127 | 127 | return; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
| 130 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
| 131 | 131 | |
| 132 | - if ( $config->get( 'WBQualityConstraintsShowConstraintViolationToNonLoggedInUsers' ) |
|
| 133 | - || $out->getUser()->isRegistered() ) { |
|
| 134 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
| 132 | + if ($config->get('WBQualityConstraintsShowConstraintViolationToNonLoggedInUsers') |
|
| 133 | + || $out->getUser()->isRegistered()) { |
|
| 134 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -15,22 +15,22 @@ |
||
| 15 | 15 | /** |
| 16 | 16 | * @param DatabaseUpdater $updater |
| 17 | 17 | */ |
| 18 | - public function onLoadExtensionSchemaUpdates( $updater ) { |
|
| 19 | - $dir = dirname( __DIR__ ) . '/sql/'; |
|
| 18 | + public function onLoadExtensionSchemaUpdates($updater) { |
|
| 19 | + $dir = dirname(__DIR__).'/sql/'; |
|
| 20 | 20 | |
| 21 | 21 | $updater->addExtensionTable( |
| 22 | 22 | 'wbqc_constraints', |
| 23 | - $dir . "/{$updater->getDB()->getType()}/tables-generated.sql" |
|
| 23 | + $dir."/{$updater->getDB()->getType()}/tables-generated.sql" |
|
| 24 | 24 | ); |
| 25 | 25 | $updater->addExtensionField( |
| 26 | 26 | 'wbqc_constraints', |
| 27 | 27 | 'constraint_id', |
| 28 | - $dir . '/patch-wbqc_constraints-constraint_id.sql' |
|
| 28 | + $dir.'/patch-wbqc_constraints-constraint_id.sql' |
|
| 29 | 29 | ); |
| 30 | 30 | $updater->addExtensionIndex( |
| 31 | 31 | 'wbqc_constraints', |
| 32 | 32 | 'wbqc_constraints_guid_uniq', |
| 33 | - $dir . '/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
| 33 | + $dir.'/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
| 34 | 34 | ); |
| 35 | 35 | } |
| 36 | 36 | |