Completed
Push — master ( 80cf2e...94aa8a )
by
unknown
06:52 queued 14s
created
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
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,44 +55,44 @@  discard block
 block discarded – undo
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()->push(
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
 			JobQueueGroup::singleton()->push(
73
-				new JobSpecification( 'constraintsTableUpdate', $params )
73
+				new JobSpecification('constraintsTableUpdate', $params)
74 74
 			);
75 75
 		}
76 76
 	}
77 77
 
78 78
 	private static function isSelectedForJobRunBasedOnPercentage() {
79 79
 		$config = MediaWikiServices::getInstance()->getMainConfig();
80
-		$percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' );
80
+		$percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio');
81 81
 
82
-		return mt_rand( 1, 100 ) <= $percentage;
82
+		return mt_rand(1, 100) <= $percentage;
83 83
 	}
84 84
 
85
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
86
-		if ( !( $change instanceof EntityChange ) ||
85
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
86
+		if (!($change instanceof EntityChange) ||
87 87
 			 $change->getAction() !== EntityChange::UPDATE ||
88
-			 !( $change->getEntityId() instanceof PropertyId )
88
+			 !($change->getEntityId() instanceof PropertyId)
89 89
 		) {
90 90
 			return false;
91 91
 		}
92 92
 
93 93
 		$info = $change->getInfo();
94 94
 
95
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
95
+		if (!array_key_exists('compactDiff', $info)) {
96 96
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
97 97
 			// so we only know that the change *might* affect the constraint statements
98 98
 			return true;
@@ -101,46 +101,46 @@  discard block
 block discarded – undo
101 101
 		/** @var EntityDiffChangedAspects $aspects */
102 102
 		$aspects = $info['compactDiff'];
103 103
 
104
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
105
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
104
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
105
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
106 106
 	}
107 107
 
108
-	public static function onArticlePurge( WikiPage $wikiPage ) {
108
+	public static function onArticlePurge(WikiPage $wikiPage) {
109 109
 		$repo = WikibaseRepo::getDefaultInstance();
110 110
 
111 111
 		$entityContentFactory = $repo->getEntityContentFactory();
112
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
113
-			$entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() );
114
-			if ( $entityId !== null ) {
112
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
113
+			$entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle());
114
+			if ($entityId !== null) {
115 115
 				$resultsCache = ResultsCache::getDefaultInstance();
116
-				$resultsCache->delete( $entityId );
116
+				$resultsCache->delete($entityId);
117 117
 			}
118 118
 		}
119 119
 	}
120 120
 
121
-	public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
121
+	public static function onBeforePageDisplay(OutputPage $out, Skin $skin) {
122 122
 		$repo = WikibaseRepo::getDefaultInstance();
123 123
 
124 124
 		$lookup = $repo->getEntityNamespaceLookup();
125 125
 		$title = $out->getTitle();
126
-		if ( $title === null ) {
126
+		if ($title === null) {
127 127
 			return;
128 128
 		}
129 129
 
130
-		if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) {
130
+		if (!$lookup->isEntityNamespace($title->getNamespace())) {
131 131
 			return;
132 132
 		}
133
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
133
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
134 134
 			return;
135 135
 		}
136 136
 
137
-		$out->addModules( 'wikibase.quality.constraints.suggestions' );
137
+		$out->addModules('wikibase.quality.constraints.suggestions');
138 138
 
139
-		if ( !$out->getUser()->isLoggedIn() ) {
139
+		if (!$out->getUser()->isLoggedIn()) {
140 140
 			return;
141 141
 		}
142 142
 
143
-		$out->addModules( 'wikibase.quality.constraints.gadget' );
143
+		$out->addModules('wikibase.quality.constraints.gadget');
144 144
 	}
145 145
 
146 146
 }
Please login to merge, or discard this patch.