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