@@ -20,46 +20,46 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | /** @inheritDoc */ |
23 | - public function onArticlePurge( $wikiPage ) { |
|
23 | + public function onArticlePurge($wikiPage) { |
|
24 | 24 | $entityContentFactory = WikibaseRepo::getEntityContentFactory(); |
25 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
25 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
26 | 26 | $entityIdLookup = WikibaseRepo::getEntityIdLookup(); |
27 | - $entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
28 | - if ( $entityId !== null ) { |
|
27 | + $entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle()); |
|
28 | + if ($entityId !== null) { |
|
29 | 29 | $resultsCache = ResultsCache::getDefaultInstance(); |
30 | - $resultsCache->delete( $entityId ); |
|
30 | + $resultsCache->delete($entityId); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** @inheritDoc */ |
36 | - public function onBeforePageDisplay( $out, $skin ): void { |
|
36 | + public function onBeforePageDisplay($out, $skin): void { |
|
37 | 37 | $lookup = WikibaseRepo::getEntityNamespaceLookup(); |
38 | 38 | $title = $out->getTitle(); |
39 | - if ( $title === null ) { |
|
39 | + if ($title === null) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) { |
|
43 | + if (!$lookup->isNamespaceWithEntities($title->getNamespace())) { |
|
44 | 44 | return; |
45 | 45 | } |
46 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
46 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $services = MediaWikiServices::getInstance(); |
51 | 51 | $config = $services->getMainConfig(); |
52 | 52 | |
53 | - $isMobileView = ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) && |
|
54 | - $services->getService( 'MobileFrontend.Context' )->shouldDisplayMobileView(); |
|
55 | - if ( $isMobileView ) { |
|
53 | + $isMobileView = ExtensionRegistry::getInstance()->isLoaded('MobileFrontend') && |
|
54 | + $services->getService('MobileFrontend.Context')->shouldDisplayMobileView(); |
|
55 | + if ($isMobileView) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
59 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
60 | 60 | |
61 | - if ( $out->getUser()->isAllowed( 'wbqc-check-constraints' ) ) { |
|
62 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
61 | + if ($out->getUser()->isAllowed('wbqc-check-constraints')) { |
|
62 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -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::getPropertyInfoLookup( $services ); |
|
60 | + $this->propertyInfoLookup = WikibaseRepo::getPropertyInfoLookup($services); |
|
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 = ( $this->newUpdateConstraintsTableJob )( $propertyIdSerialization ); |
|
81 | + $startTime = microtime(true); |
|
82 | + $job = ($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 |