@@ -29,25 +29,25 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @param DatabaseUpdater $updater |
31 | 31 | */ |
32 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
32 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
33 | 33 | $updater->addExtensionTable( |
34 | 34 | 'wbqc_constraints', |
35 | - __DIR__ . '/../sql/create_wbqc_constraints.sql' |
|
35 | + __DIR__.'/../sql/create_wbqc_constraints.sql' |
|
36 | 36 | ); |
37 | 37 | $updater->addExtensionField( |
38 | 38 | 'wbqc_constraints', |
39 | 39 | 'constraint_id', |
40 | - __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
40 | + __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
41 | 41 | ); |
42 | 42 | $updater->addExtensionIndex( |
43 | 43 | 'wbqc_constraints', |
44 | 44 | 'wbqc_constraints_guid_uniq', |
45 | - __DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
45 | + __DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - public static function onWikibaseChange( Change $change ) { |
|
50 | - if ( !( $change instanceof EntityChange ) ) { |
|
49 | + public static function onWikibaseChange(Change $change) { |
|
50 | + if (!($change instanceof EntityChange)) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
@@ -56,44 +56,44 @@ discard block |
||
56 | 56 | |
57 | 57 | // If jobs are enabled and the results would be stored in some way run a job. |
58 | 58 | if ( |
59 | - $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) && |
|
60 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) && |
|
59 | + $config->get('WBQualityConstraintsEnableConstraintsCheckJobs') && |
|
60 | + $config->get('WBQualityConstraintsCacheCheckConstraintsResults') && |
|
61 | 61 | self::isSelectedForJobRunBasedOnPercentage() |
62 | 62 | ) { |
63 | - $params = [ 'entityId' => $change->getEntityId()->getSerialization() ]; |
|
63 | + $params = ['entityId' => $change->getEntityId()->getSerialization()]; |
|
64 | 64 | JobQueueGroup::singleton()->push( |
65 | - new JobSpecification( CheckConstraintsJob::COMMAND, $params ) |
|
65 | + new JobSpecification(CheckConstraintsJob::COMMAND, $params) |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
69 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
70 | - self::isConstraintStatementsChange( $config, $change ) |
|
69 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
70 | + self::isConstraintStatementsChange($config, $change) |
|
71 | 71 | ) { |
72 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
72 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
73 | 73 | JobQueueGroup::singleton()->push( |
74 | - new JobSpecification( 'constraintsTableUpdate', $params ) |
|
74 | + new JobSpecification('constraintsTableUpdate', $params) |
|
75 | 75 | ); |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | private static function isSelectedForJobRunBasedOnPercentage() { |
80 | 80 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
81 | - $percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' ); |
|
81 | + $percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio'); |
|
82 | 82 | |
83 | - return mt_rand( 1, 100 ) <= $percentage; |
|
83 | + return mt_rand(1, 100) <= $percentage; |
|
84 | 84 | } |
85 | 85 | |
86 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
87 | - if ( !( $change instanceof EntityChange ) || |
|
86 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
87 | + if (!($change instanceof EntityChange) || |
|
88 | 88 | $change->getAction() !== EntityChange::UPDATE || |
89 | - !( $change->getEntityId() instanceof PropertyId ) |
|
89 | + !($change->getEntityId() instanceof PropertyId) |
|
90 | 90 | ) { |
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | $info = $change->getInfo(); |
95 | 95 | |
96 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
96 | + if (!array_key_exists('compactDiff', $info)) { |
|
97 | 97 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
98 | 98 | // so we only know that the change *might* affect the constraint statements |
99 | 99 | return true; |
@@ -102,46 +102,46 @@ discard block |
||
102 | 102 | /** @var EntityDiffChangedAspects $aspects */ |
103 | 103 | $aspects = $info['compactDiff']; |
104 | 104 | |
105 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
106 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
105 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
106 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
107 | 107 | } |
108 | 108 | |
109 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
109 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
110 | 110 | $repo = WikibaseRepo::getDefaultInstance(); |
111 | 111 | |
112 | 112 | $entityContentFactory = $repo->getEntityContentFactory(); |
113 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
114 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
115 | - if ( $entityId !== null ) { |
|
113 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
114 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
115 | + if ($entityId !== null) { |
|
116 | 116 | $resultsCache = ResultsCache::getDefaultInstance(); |
117 | - $resultsCache->delete( $entityId ); |
|
117 | + $resultsCache->delete($entityId); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
122 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
123 | 123 | $repo = WikibaseRepo::getDefaultInstance(); |
124 | 124 | |
125 | 125 | $lookup = $repo->getEntityNamespaceLookup(); |
126 | 126 | $title = $out->getTitle(); |
127 | - if ( $title === null ) { |
|
127 | + if ($title === null) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
131 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
134 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
138 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
139 | 139 | |
140 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
140 | + if (!$out->getUser()->isLoggedIn()) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
144 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | * @param User $user |
151 | 151 | * @param array[] &$prefs |
152 | 152 | */ |
153 | - public static function onGetBetaFeaturePreferences( User $user, array &$prefs ) { |
|
153 | + public static function onGetBetaFeaturePreferences(User $user, array &$prefs) { |
|
154 | 154 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
155 | - $extensionAssetsPath = $config->get( 'ExtensionAssetsPath' ); |
|
156 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) ) { |
|
155 | + $extensionAssetsPath = $config->get('ExtensionAssetsPath'); |
|
156 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature')) { |
|
157 | 157 | $prefs['constraint-suggestions'] = [ |
158 | 158 | 'label-message' => 'wbqc-beta-feature-label-message', |
159 | 159 | 'desc-message' => 'wbqc-beta-feature-description-message', |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | * @param array &$vars |
178 | 178 | * @param OutputPage $out |
179 | 179 | */ |
180 | - public static function addVariables( &$vars, OutputPage $out ) { |
|
180 | + public static function addVariables(&$vars, OutputPage $out) { |
|
181 | 181 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
182 | 182 | |
183 | - $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
184 | - $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get( 'WBQualityConstraintsOneOfConstraintId' ); |
|
185 | - $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ); |
|
186 | - $vars['wbQualityConstraintsPropertyId'] = $config->get( 'WBQualityConstraintsPropertyId' ); |
|
187 | - $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
183 | + $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
184 | + $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get('WBQualityConstraintsOneOfConstraintId'); |
|
185 | + $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get('WBQualityConstraintsAllowedQualifiersConstraintId'); |
|
186 | + $vars['wbQualityConstraintsPropertyId'] = $config->get('WBQualityConstraintsPropertyId'); |
|
187 | + $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |