blob: 031280f4cd7c3a922fd073ec9969923888221ec6 (
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
|
<?php
namespace SMW\MediaWiki\Jobs;
use SMW\MediaWiki\Job;
use SMW\ApplicationFactory;
use SMW\SQLStore\QueryEngine\FulltextSearchTableFactory;
use Title;
/**
* @license GNU GPL v2+
* @since 2.5
*
* @author mwjames
*/
class FulltextSearchTableRebuildJob extends Job {
/**
* @since 2.5
*
* @param Title $title
* @param array $params job parameters
*/
public function __construct( Title $title, $params = [] ) {
parent::__construct( 'smw.fulltextSearchTableRebuild', $title, $params );
}
/**
* @see Job::run
*
* @since 2.5
*/
public function run() {
if ( $this->waitOnCommandLineMode() ) {
return true;
}
$fulltextSearchTableFactory = new FulltextSearchTableFactory();
// Only the SQLStore is supported
$searchTableRebuilder = $fulltextSearchTableFactory->newSearchTableRebuilder(
ApplicationFactory::getInstance()->getStore( '\SMW\SQLStore\SQLStore' )
);
if ( $this->hasParameter( 'table' ) ) {
$searchTableRebuilder->rebuildByTable( $this->getParameter( 'table' ) );
} elseif ( $this->hasParameter( 'mode' ) && $this->getParameter( 'mode' ) === 'full' ) {
$searchTableRebuilder->rebuild();
} else {
$searchTableRebuilder->flushTable();
$this->createJobsFromTableList( $searchTableRebuilder->getQualifiedTableList() );
}
return true;
}
private function createJobsFromTableList( $tableList ) {
if ( $tableList === [] ) {
return;
}
foreach ( $tableList as $tableName ) {
$fulltextSearchTableRebuildJob = new self( $this->getTitle(), [
'table' => $tableName
] );
$fulltextSearchTableRebuildJob->insert();
}
}
}
|