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