blob: f1899c69e8968634b9b094547c07fd1ed3883d0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
namespace SMW\MediaWiki\Jobs;
use SMW\MediaWiki\Job;
use SMW\ApplicationFactory;
use Title;
/**
* @license GNU GPL v2+
* @since 2.5
*
* @author mwjames
*/
class PropertyStatisticsRebuildJob extends Job {
/**
* @since 2.5
*
* @param Title $title
* @param array $params job parameters
*/
public function __construct( Title $title, $params = [] ) {
parent::__construct( 'smw.propertyStatisticsRebuild', $title, $params );
$this->removeDuplicates = true;
}
/**
* @see Job::run
*
* @since 2.5
*/
public function run() {
if ( $this->waitOnCommandLineMode() ) {
return true;
}
$deferredCallableUpdate = ApplicationFactory::getInstance()->newDeferredTransactionalCallableUpdate(
[ $this, 'rebuild' ]
);
$deferredCallableUpdate->setOrigin( __METHOD__ );
$deferredCallableUpdate->runAsAutoCommit();
$deferredCallableUpdate->pushUpdate();
return true;
}
public function rebuild() {
$applicationFactory = ApplicationFactory::getInstance();
$maintenanceFactory = $applicationFactory->newMaintenanceFactory();
// Use a fixed store to avoid issues like "Call to undefined method
// SMW\SPARQLStore\SPARQLStore::getDataItemHandlerForDIType" because
// the property statistics table and hereby its update is bound to
// the SQLStore
$propertyStatisticsRebuilder = $maintenanceFactory->newPropertyStatisticsRebuilder(
$applicationFactory->getStore( '\SMW\SQLStore\SQLStore' )
);
$propertyStatisticsRebuilder->rebuild();
}
}
|