@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @param DatabaseUpdater $updater |
30 | 30 | */ |
31 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
32 | - $updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' ); |
|
33 | - $updater->addExtensionField( 'wbqc_constraints', 'constraint_id', __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' ); |
|
31 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
32 | + $updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql'); |
|
33 | + $updater->addExtensionField('wbqc_constraints', 'constraint_id', __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql'); |
|
34 | 34 | } |
35 | 35 | |
36 | - public static function onWikibaseChange( Change $change ) { |
|
36 | + public static function onWikibaseChange(Change $change) { |
|
37 | 37 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
38 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
39 | - self::isConstraintStatementsChange( $config, $change ) |
|
38 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
39 | + self::isConstraintStatementsChange($config, $change) |
|
40 | 40 | ) { |
41 | 41 | /** @var EntityChange $change */ |
42 | 42 | $title = Title::newMainPage(); |
43 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
43 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
44 | 44 | JobQueueGroup::singleton()->push( |
45 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
45 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
46 | 46 | ); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
51 | - if ( !( $change instanceof EntityChange ) || |
|
50 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
51 | + if (!($change instanceof EntityChange) || |
|
52 | 52 | $change->getAction() !== EntityChange::UPDATE || |
53 | - !( $change->getEntityId() instanceof PropertyId ) |
|
53 | + !($change->getEntityId() instanceof PropertyId) |
|
54 | 54 | ) { |
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $info = $change->getInfo(); |
59 | 59 | |
60 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
60 | + if (!array_key_exists('compactDiff', $info)) { |
|
61 | 61 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
62 | 62 | // so we only know that the change *might* affect the constraint statements |
63 | 63 | return true; |
@@ -66,46 +66,46 @@ discard block |
||
66 | 66 | /** @var EntityDiffChangedAspects $aspects */ |
67 | 67 | $aspects = $info['compactDiff']; |
68 | 68 | |
69 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
70 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
69 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
70 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
73 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
74 | 74 | $repo = WikibaseRepo::getDefaultInstance(); |
75 | 75 | |
76 | 76 | $entityContentFactory = $repo->getEntityContentFactory(); |
77 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
78 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
79 | - if ( $entityId !== null ) { |
|
77 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
78 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
79 | + if ($entityId !== null) { |
|
80 | 80 | $resultsCache = ResultsCache::getDefaultInstance(); |
81 | - $resultsCache->delete( $entityId ); |
|
81 | + $resultsCache->delete($entityId); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
86 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
87 | 87 | $repo = WikibaseRepo::getDefaultInstance(); |
88 | 88 | |
89 | 89 | $lookup = $repo->getEntityNamespaceLookup(); |
90 | 90 | $title = $out->getTitle(); |
91 | - if ( $title === null ) { |
|
91 | + if ($title === null) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
95 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
98 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
102 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
103 | 103 | |
104 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
104 | + if (!$out->getUser()->isLoggedIn()) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
108 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * @param array &$vars |
114 | 114 | * @param OutputPage $out |
115 | 115 | */ |
116 | - public static function addVariables( &$vars, OutputPage $out ) { |
|
116 | + public static function addVariables(&$vars, OutputPage $out) { |
|
117 | 117 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
118 | 118 | |
119 | - $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
120 | - $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get( 'WBQualityConstraintsOneOfConstraintId' ); |
|
121 | - $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
119 | + $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
120 | + $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get('WBQualityConstraintsOneOfConstraintId'); |
|
121 | + $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | } |