@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | use WikibaseQuality\ConstraintReport\Job\UpdateConstraintsTableJob; |
| 11 | 11 | |
| 12 | 12 | // @codeCoverageIgnoreStart |
| 13 | -$basePath = getenv( "MW_INSTALL_PATH" ) !== false |
|
| 14 | - ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../.."; |
|
| 13 | +$basePath = getenv("MW_INSTALL_PATH") !== false |
|
| 14 | + ? getenv("MW_INSTALL_PATH") : __DIR__."/../../.."; |
|
| 15 | 15 | |
| 16 | -require_once $basePath . "/maintenance/Maintenance.php"; |
|
| 16 | +require_once $basePath."/maintenance/Maintenance.php"; |
|
| 17 | 17 | // @codeCoverageIgnoreEnd |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -42,56 +42,56 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function __construct() { |
| 44 | 44 | parent::__construct(); |
| 45 | - $this->newUpdateConstraintsTableJob = static function ( $propertyIdSerialization ) { |
|
| 45 | + $this->newUpdateConstraintsTableJob = static function($propertyIdSerialization) { |
|
| 46 | 46 | return UpdateConstraintsTableJob::newFromGlobalState( |
| 47 | 47 | Title::newMainPage(), |
| 48 | - [ 'propertyId' => $propertyIdSerialization ] |
|
| 48 | + ['propertyId' => $propertyIdSerialization] |
|
| 49 | 49 | ); |
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | - $this->addDescription( 'Imports property constraints from statements on properties' ); |
|
| 53 | - $this->requireExtension( 'WikibaseQualityConstraints' ); |
|
| 54 | - $this->setBatchSize( 10 ); |
|
| 52 | + $this->addDescription('Imports property constraints from statements on properties'); |
|
| 53 | + $this->requireExtension('WikibaseQualityConstraints'); |
|
| 54 | + $this->setBatchSize(10); |
|
| 55 | 55 | |
| 56 | 56 | // Wikibase classes are not yet loaded, so setup services in a callback run in execute |
| 57 | 57 | // that can be overridden in tests. |
| 58 | - $this->setupServices = function () { |
|
| 58 | + $this->setupServices = function() { |
|
| 59 | 59 | $services = MediaWikiServices::getInstance(); |
| 60 | - $this->propertyInfoLookup = WikibaseRepo::getStore( $services )->getPropertyInfoLookup(); |
|
| 60 | + $this->propertyInfoLookup = WikibaseRepo::getStore($services)->getPropertyInfoLookup(); |
|
| 61 | 61 | }; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function execute() { |
| 65 | - ( $this->setupServices )(); |
|
| 66 | - if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) { |
|
| 67 | - $this->error( 'Constraint statements are not enabled. Aborting.' ); |
|
| 65 | + ($this->setupServices)(); |
|
| 66 | + if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) { |
|
| 67 | + $this->error('Constraint statements are not enabled. Aborting.'); |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $propertyInfos = $this->propertyInfoLookup->getAllPropertyInfo(); |
| 72 | - $propertyIds = array_keys( $propertyInfos ); |
|
| 72 | + $propertyIds = array_keys($propertyInfos); |
|
| 73 | 73 | |
| 74 | - foreach ( array_chunk( $propertyIds, $this->getBatchSize() ) as $propertyIdsChunk ) { |
|
| 75 | - foreach ( $propertyIdsChunk as $propertyIdSerialization ) { |
|
| 76 | - $this->output( sprintf( |
|
| 74 | + foreach (array_chunk($propertyIds, $this->getBatchSize()) as $propertyIdsChunk) { |
|
| 75 | + foreach ($propertyIdsChunk as $propertyIdSerialization) { |
|
| 76 | + $this->output(sprintf( |
|
| 77 | 77 | 'Importing constraint statements for % 6s... ', |
| 78 | 78 | $propertyIdSerialization ), |
| 79 | 79 | $propertyIdSerialization |
| 80 | 80 | ); |
| 81 | - $startTime = microtime( true ); |
|
| 82 | - $job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization ); |
|
| 81 | + $startTime = microtime(true); |
|
| 82 | + $job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization); |
|
| 83 | 83 | $job->run(); |
| 84 | - $endTime = microtime( true ); |
|
| 85 | - $millis = ( $endTime - $startTime ) * 1000; |
|
| 86 | - $this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization ); |
|
| 84 | + $endTime = microtime(true); |
|
| 85 | + $millis = ($endTime - $startTime) * 1000; |
|
| 86 | + $this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $this->output( 'Waiting for replication... ', 'waitForReplication' ); |
|
| 90 | - $startTime = microtime( true ); |
|
| 89 | + $this->output('Waiting for replication... ', 'waitForReplication'); |
|
| 90 | + $startTime = microtime(true); |
|
| 91 | 91 | $this->waitForReplication(); |
| 92 | - $endTime = microtime( true ); |
|
| 93 | - $millis = ( $endTime - $startTime ) * 1000; |
|
| 94 | - $this->output( sprintf( 'done in % 6.2f ms.', $millis ), 'waitForReplication' ); |
|
| 92 | + $endTime = microtime(true); |
|
| 93 | + $millis = ($endTime - $startTime) * 1000; |
|
| 94 | + $this->output(sprintf('done in % 6.2f ms.', $millis), 'waitForReplication'); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |