Completed
Push — master ( 563323...e24852 )
by
unknown
01:54 queued 11s
created
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 use Wikimedia\Rdbms\ILBFactory;
12 12
 
13 13
 // @codeCoverageIgnoreStart
14
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
15
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
14
+$basePath = getenv("MW_INSTALL_PATH") !== false
15
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
16 16
 
17
-require_once $basePath . "/maintenance/Maintenance.php";
17
+require_once $basePath."/maintenance/Maintenance.php";
18 18
 // @codeCoverageIgnoreEnd
19 19
 
20 20
 /**
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public function __construct() {
48 48
 		parent::__construct();
49
-		$this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) {
49
+		$this->newUpdateConstraintsTableJob = function($propertyIdSerialization) {
50 50
 			return UpdateConstraintsTableJob::newFromGlobalState(
51 51
 				Title::newMainPage(),
52
-				[ 'propertyId' => $propertyIdSerialization ]
52
+				['propertyId' => $propertyIdSerialization]
53 53
 			);
54 54
 		};
55 55
 
56
-		$this->addDescription( 'Imports property constraints from statements on properties' );
57
-		$this->requireExtension( 'WikibaseQualityConstraints' );
58
-		$this->setBatchSize( 10 );
56
+		$this->addDescription('Imports property constraints from statements on properties');
57
+		$this->requireExtension('WikibaseQualityConstraints');
58
+		$this->setBatchSize(10);
59 59
 
60 60
 		// Wikibase classes are not yet loaded, so setup services in a callback run in execute
61 61
 		// that can be overridden in tests.
62
-		$this->setupServices = function () {
62
+		$this->setupServices = function() {
63 63
 			$repo = WikibaseRepo::getDefaultInstance();
64 64
 			$this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup();
65 65
 			$this->lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
@@ -67,36 +67,36 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	public function execute() {
70
-		( $this->setupServices )();
71
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
72
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
70
+		($this->setupServices)();
71
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
72
+			$this->error('Constraint statements are not enabled. Aborting.');
73 73
 			return;
74 74
 		}
75 75
 
76 76
 		$propertyInfos = $this->propertyInfoLookup->getAllPropertyInfo();
77
-		$propertyIds = array_keys( $propertyInfos );
77
+		$propertyIds = array_keys($propertyInfos);
78 78
 
79
-		foreach ( array_chunk( $propertyIds, $this->getBatchSize() ) as $propertyIdsChunk ) {
80
-			foreach ( $propertyIdsChunk as $propertyIdSerialization ) {
81
-				$this->output( sprintf(
79
+		foreach (array_chunk($propertyIds, $this->getBatchSize()) as $propertyIdsChunk) {
80
+			foreach ($propertyIdsChunk as $propertyIdSerialization) {
81
+				$this->output(sprintf(
82 82
 					'Importing constraint statements for % 6s... ',
83 83
 					$propertyIdSerialization ),
84 84
 					$propertyIdSerialization
85 85
 				);
86
-				$startTime = microtime( true );
87
-				$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
86
+				$startTime = microtime(true);
87
+				$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
88 88
 				$job->run();
89
-				$endTime = microtime( true );
90
-				$millis = ( $endTime - $startTime ) * 1000;
91
-				$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
89
+				$endTime = microtime(true);
90
+				$millis = ($endTime - $startTime) * 1000;
91
+				$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
92 92
 			}
93 93
 
94
-			$this->output( 'Waiting for replication... ', 'waitForReplication' );
95
-			$startTime = microtime( true );
94
+			$this->output('Waiting for replication... ', 'waitForReplication');
95
+			$startTime = microtime(true);
96 96
 			$this->lbFactory->waitForReplication();
97
-			$endTime = microtime( true );
98
-			$millis = ( $endTime - $startTime ) * 1000;
99
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), 'waitForReplication' );
97
+			$endTime = microtime(true);
98
+			$millis = ($endTime - $startTime) * 1000;
99
+			$this->output(sprintf('done in % 6.2f ms.', $millis), 'waitForReplication');
100 100
 		}
101 101
 	}
102 102
 
Please login to merge, or discard this patch.