Completed
Push — master ( 4301d4...442da4 )
by
unknown
04:40
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 ( !$out->getJsConfigVars()['wbIsEditView'] ) {
135
+		if (!$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.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 use Wikibase\Repo\WikibaseRepo;
10 10
 
11 11
 // @codeCoverageIgnoreStart
12
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
13
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
12
+$basePath = getenv("MW_INSTALL_PATH") !== false
13
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
14 14
 
15
-require_once $basePath . "/maintenance/Maintenance.php";
15
+require_once $basePath."/maintenance/Maintenance.php";
16 16
 // @codeCoverageIgnoreEnd
17 17
 
18 18
 /**
@@ -38,30 +38,30 @@  discard block
 block discarded – undo
38 38
 		parent::__construct();
39 39
 		$repo = WikibaseRepo::getDefaultInstance();
40 40
 		$this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup();
41
-		$this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) {
41
+		$this->newUpdateConstraintsTableJob = function($propertyIdSerialization) {
42 42
 			return UpdateConstraintsTableJob::newFromGlobalState(
43 43
 				Title::newMainPage(),
44
-				[ 'propertyId' => $propertyIdSerialization ]
44
+				['propertyId' => $propertyIdSerialization]
45 45
 			);
46 46
 		};
47 47
 
48
-		$this->addDescription( 'Imports property constraints from statements on properties' );
48
+		$this->addDescription('Imports property constraints from statements on properties');
49 49
 	}
50 50
 
51 51
 	public function execute() {
52
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
53
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
52
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
53
+			$this->error('Constraint statements are not enabled. Aborting.');
54 54
 			return;
55 55
 		}
56 56
 
57
-		foreach ( $this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
58
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
59
-			$startTime = microtime( true );
60
-			$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
57
+		foreach ($this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
58
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
59
+			$startTime = microtime(true);
60
+			$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
61 61
 			$job->run();
62
-			$endTime = microtime( true );
63
-			$millis = ( $endTime - $startTime ) * 1000;
64
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
62
+			$endTime = microtime(true);
63
+			$millis = ($endTime - $startTime) * 1000;
64
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
65 65
 		}
66 66
 	}
67 67
 
Please login to merge, or discard this patch.