Completed
Push — master ( 0f0d16...377111 )
by
unknown
02:58
created
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return bool
32 32
 	 */
33
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
34
-		$updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' );
33
+	public static function onCreateSchema(DatabaseUpdater $updater) {
34
+		$updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql');
35 35
 		return true;
36 36
 	}
37 37
 
38
-	public static function onWikibaseChange( Change $change ) {
38
+	public static function onWikibaseChange(Change $change) {
39 39
 		$config = MediaWikiServices::getInstance()->getMainConfig();
40
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
41
-			self::isConstraintStatementsChange( $config, $change )
40
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
41
+			self::isConstraintStatementsChange($config, $change)
42 42
 		) {
43 43
 			/** @var EntityChange $change */
44 44
 			$title = Title::newMainPage();
45
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
45
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
46 46
 			JobQueueGroup::singleton()->push(
47
-				new JobSpecification( 'constraintsTableUpdate', $params, [], $title )
47
+				new JobSpecification('constraintsTableUpdate', $params, [], $title)
48 48
 			);
49 49
 		}
50 50
 	}
51 51
 
52
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
53
-		if ( !( $change instanceof EntityChange ) ||
52
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
53
+		if (!($change instanceof EntityChange) ||
54 54
 			 $change->getAction() !== EntityChange::UPDATE ||
55
-			 !( $change->getEntityId() instanceof PropertyId )
55
+			 !($change->getEntityId() instanceof PropertyId)
56 56
 		) {
57 57
 			return false;
58 58
 		}
59 59
 
60 60
 		$info = $change->getInfo();
61 61
 
62
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
62
+		if (!array_key_exists('compactDiff', $info)) {
63 63
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
64 64
 			// so we only know that the change *might* affect the constraint statements
65 65
 			return true;
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 		/** @var EntityDiffChangedAspects $aspects */
69 69
 		$aspects = $info['compactDiff'];
70 70
 
71
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
72
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
71
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
72
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
73 73
 	}
74 74
 
75
-	public static function onArticlePurge( WikiPage $wikiPage ) {
75
+	public static function onArticlePurge(WikiPage $wikiPage) {
76 76
 		$repo = WikibaseRepo::getDefaultInstance();
77 77
 
78 78
 		$entityContentFactory = $repo->getEntityContentFactory();
79
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
80
-			$entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() );
79
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
80
+			$entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle());
81 81
 			$resultsCache = ResultsCache::getDefaultInstance();
82
-			$resultsCache->delete( $entityId );
82
+			$resultsCache->delete($entityId);
83 83
 		}
84 84
 	}
85 85
 
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 	 * @param int $timestamp UTC timestamp (seconds since the Epoch)
89 89
 	 * @return bool
90 90
 	 */
91
-	public static function isGadgetEnabledForUserName( $userName, $timestamp ) {
91
+	public static function isGadgetEnabledForUserName($userName, $timestamp) {
92 92
 		$initial = $userName[0];
93 93
 
94
-		if ( $initial === 'Z' ) {
94
+		if ($initial === 'Z') {
95 95
 			$firstWeek = 0;
96
-		} elseif ( $initial >= 'W' && $initial < 'Z' ) {
96
+		} elseif ($initial >= 'W' && $initial < 'Z') {
97 97
 			$firstWeek = 1;
98
-		} elseif ( $initial >= 'T' && $initial < 'W' ) {
98
+		} elseif ($initial >= 'T' && $initial < 'W') {
99 99
 			$firstWeek = 2;
100
-		} elseif ( $initial >= 'N' && $initial < 'T' ) {
100
+		} elseif ($initial >= 'N' && $initial < 'T') {
101 101
 			$firstWeek = 3;
102
-		} elseif ( $initial >= 'E' && $initial < 'N' ) {
102
+		} elseif ($initial >= 'E' && $initial < 'N') {
103 103
 			$firstWeek = 4;
104 104
 		} else {
105 105
 			$firstWeek = 5;
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 		return $timestamp >= $threshold;
118 118
 	}
119 119
 
120
-	public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
120
+	public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) {
121 121
 		$repo = WikibaseRepo::getDefaultInstance();
122 122
 
123 123
 		$lookup = $repo->getEntityNamespaceLookup();
124 124
 		$title = $out->getTitle();
125
-		if ( $title === null ) {
125
+		if ($title === null) {
126 126
 			return;
127 127
 		}
128 128
 
129
-		if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) {
129
+		if (!$lookup->isEntityNamespace($title->getNamespace())) {
130 130
 			return;
131 131
 		}
132
-		if ( !$out->getUser()->isLoggedIn() ) {
132
+		if (!$out->getUser()->isLoggedIn()) {
133 133
 			return;
134 134
 		}
135
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
135
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
136 136
 			return;
137 137
 		}
138 138
 
139
-		if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) {
140
-			$out->addModules( 'wikibase.quality.constraints.gadget' );
139
+		if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) {
140
+			$out->addModules('wikibase.quality.constraints.gadget');
141 141
 		}
142 142
 	}
143 143
 
Please login to merge, or discard this patch.