@@ -31,48 +31,48 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param DatabaseUpdater $updater |
33 | 33 | */ |
34 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
34 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
35 | 35 | $updater->addExtensionTable( |
36 | 36 | 'wbqc_constraints', |
37 | - __DIR__ . '/../sql/create_wbqc_constraints.sql' |
|
37 | + __DIR__.'/../sql/create_wbqc_constraints.sql' |
|
38 | 38 | ); |
39 | 39 | $updater->addExtensionField( |
40 | 40 | 'wbqc_constraints', |
41 | 41 | 'constraint_id', |
42 | - __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
42 | + __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
43 | 43 | ); |
44 | 44 | $updater->addExtensionIndex( |
45 | 45 | 'wbqc_constraints', |
46 | 46 | 'wbqc_constraints_guid_uniq', |
47 | - __DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
47 | + __DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | - public static function onWikibaseChange( Change $change ) { |
|
51 | + public static function onWikibaseChange(Change $change) { |
|
52 | 52 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
53 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
54 | - self::isConstraintStatementsChange( $config, $change ) |
|
53 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
54 | + self::isConstraintStatementsChange($config, $change) |
|
55 | 55 | ) { |
56 | 56 | /** @var EntityChange $change */ |
57 | 57 | $title = Title::newMainPage(); |
58 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
58 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
59 | 59 | JobQueueGroup::singleton()->push( |
60 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
60 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
66 | - if ( !( $change instanceof EntityChange ) || |
|
65 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
66 | + if (!($change instanceof EntityChange) || |
|
67 | 67 | $change->getAction() !== EntityChange::UPDATE || |
68 | - !( $change->getEntityId() instanceof PropertyId ) |
|
68 | + !($change->getEntityId() instanceof PropertyId) |
|
69 | 69 | ) { |
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | 73 | $info = $change->getInfo(); |
74 | 74 | |
75 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
75 | + if (!array_key_exists('compactDiff', $info)) { |
|
76 | 76 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
77 | 77 | // so we only know that the change *might* affect the constraint statements |
78 | 78 | return true; |
@@ -81,46 +81,46 @@ discard block |
||
81 | 81 | /** @var EntityDiffChangedAspects $aspects */ |
82 | 82 | $aspects = $info['compactDiff']; |
83 | 83 | |
84 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
85 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
84 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
85 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
86 | 86 | } |
87 | 87 | |
88 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
88 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
89 | 89 | $repo = WikibaseRepo::getDefaultInstance(); |
90 | 90 | |
91 | 91 | $entityContentFactory = $repo->getEntityContentFactory(); |
92 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
93 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
94 | - if ( $entityId !== null ) { |
|
92 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
93 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
94 | + if ($entityId !== null) { |
|
95 | 95 | $resultsCache = ResultsCache::getDefaultInstance(); |
96 | - $resultsCache->delete( $entityId ); |
|
96 | + $resultsCache->delete($entityId); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
101 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
102 | 102 | $repo = WikibaseRepo::getDefaultInstance(); |
103 | 103 | |
104 | 104 | $lookup = $repo->getEntityNamespaceLookup(); |
105 | 105 | $title = $out->getTitle(); |
106 | - if ( $title === null ) { |
|
106 | + if ($title === null) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
110 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
113 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
117 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
118 | 118 | |
119 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
119 | + if (!$out->getUser()->isLoggedIn()) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
123 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | * @param User $user |
130 | 130 | * @param array[] &$prefs |
131 | 131 | */ |
132 | - public static function onGetBetaFeaturePreferences( User $user, array &$prefs ) { |
|
132 | + public static function onGetBetaFeaturePreferences(User $user, array &$prefs) { |
|
133 | 133 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
134 | - $extensionAssetsPath = $config->get( 'ExtensionAssetsPath' ); |
|
135 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) ) { |
|
134 | + $extensionAssetsPath = $config->get('ExtensionAssetsPath'); |
|
135 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature')) { |
|
136 | 136 | $prefs['constraint-suggestions'] = [ |
137 | 137 | 'label-message' => 'wbqc-beta-feature-label-message', |
138 | 138 | 'desc-message' => 'wbqc-beta-feature-description-message', |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * @param array &$vars |
157 | 157 | * @param OutputPage $out |
158 | 158 | */ |
159 | - public static function addVariables( &$vars, OutputPage $out ) { |
|
159 | + public static function addVariables(&$vars, OutputPage $out) { |
|
160 | 160 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
161 | 161 | |
162 | - $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
163 | - $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get( 'WBQualityConstraintsOneOfConstraintId' ); |
|
164 | - $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ); |
|
165 | - $vars['wbQualityConstraintsPropertyId'] = $config->get( 'WBQualityConstraintsPropertyId' ); |
|
166 | - $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
162 | + $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
163 | + $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get('WBQualityConstraintsOneOfConstraintId'); |
|
164 | + $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get('WBQualityConstraintsAllowedQualifiersConstraintId'); |
|
165 | + $vars['wbQualityConstraintsPropertyId'] = $config->get('WBQualityConstraintsPropertyId'); |
|
166 | + $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
167 | 167 | |
168 | 168 | $vars['wbQualityConstraintsSuggestionsGloballyEnabled'] = false; |
169 | 169 | |
170 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) && |
|
171 | - ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) && |
|
172 | - BetaFeatures::isFeatureEnabled( $out->getUser(), 'constraint-suggestions' ) |
|
170 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature') && |
|
171 | + ExtensionRegistry::getInstance()->isLoaded('BetaFeatures') && |
|
172 | + BetaFeatures::isFeatureEnabled($out->getUser(), 'constraint-suggestions') |
|
173 | 173 | ) { |
174 | 174 | $vars['wbQualityConstraintsSuggestionsGloballyEnabled'] = true; |
175 | 175 | } |