blob: 03b3679e24a0f509fc5287ec7db7108fc5647e2c (
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
67
68
69
70
71
72
73
74
|
<?php
namespace SMW\Maintenance;
use SMW\SQLStore\SimplePropertyStatisticsRebuilder;
use SMW\SQLStore\PropertyStatisticsTable;
use SMW\Reporter\ObservableMessageReporter;
use SMW\StoreFactory;
$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : __DIR__ . '/../../..';
require_once $basePath . '/maintenance/Maintenance.php';
/**
* Maintenance script for rebuilding the property usage statistics.
*
* TODO: make this work with all stores (Right now it only works with SQLStore3)
*
* @since 1.9
*
* @file
* @ingroup SMW
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class RebuildPropertyStatistics extends \Maintenance {
public function __construct() {
$this->mDescription = 'Rebuild the property usage statistics (only works with SQLStore3 for now)';
parent::__construct();
}
/**
* @see Maintenance::execute
*/
public function execute() {
if ( !defined( 'SMW_VERSION' ) ) {
$this->output( "You need to have SMW enabled in order to use this maintenance script!\n\n" );
exit;
}
$store = StoreFactory::getStore();
$statsTable = new PropertyStatisticsTable(
$store->getDatabase(),
\SMWSQLStore3::PROPERTY_STATISTICS_TABLE
);
// Need to instantiate an extra object here since we cannot make this class itself
// into a MessageReporter since the maintenance script does not load the interface in time.
$reporter = new ObservableMessageReporter();
$reporter->registerReporterCallback( array( $this, 'reportMessage' ) );
$statisticsRebuilder = new SimplePropertyStatisticsRebuilder( $store, $reporter );
$statisticsRebuilder->rebuild( $statsTable );
}
/**
* @see Maintenance::reportMessage
*
* @since 1.9
*
* @param string $message
*/
public function reportMessage( $message ) {
$this->output( $message );
}
}
$maintClass = 'SMW\Maintenance\RebuildPropertyStatistics';
require_once( RUN_MAINTENANCE_IF_MAIN );
|