Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
SqliteCreateSearchIndexTask | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Installer\Task; |
4 | |
5 | use MediaWiki\Status\Status; |
6 | use Wikimedia\Rdbms\DatabaseSqlite; |
7 | |
8 | /** |
9 | * Create the SQLite search index |
10 | * |
11 | * @internal For use by the installer |
12 | */ |
13 | class SqliteCreateSearchIndexTask extends Task { |
14 | public function getName() { |
15 | return 'search'; |
16 | } |
17 | |
18 | public function execute(): Status { |
19 | $status = Status::newGood(); |
20 | $db = $this->definitelyGetConnection( ITaskContext::CONN_CREATE_TABLES ); |
21 | $module = DatabaseSqlite::getFulltextSearchModule(); |
22 | $searchIndexSql = (string)$db->newSelectQueryBuilder() |
23 | ->select( 'sql' ) |
24 | ->from( $db->addIdentifierQuotes( 'sqlite_master' ) ) |
25 | ->where( [ 'tbl_name' => $db->tableName( 'searchindex', 'raw' ) ] ) |
26 | ->caller( __METHOD__ )->fetchField(); |
27 | $fts3tTable = ( stristr( $searchIndexSql, 'fts' ) !== false ); |
28 | |
29 | if ( $fts3tTable && !$module ) { |
30 | $status->warning( 'config-sqlite-fts3-downgrade' ); |
31 | $this->applySourceFile( $db, 'archives/searchindex-no-fts.sql' ); |
32 | } elseif ( !$fts3tTable && $module == 'FTS3' ) { |
33 | $this->applySourceFile( $db, 'archives/searchindex-fts3.sql' ); |
34 | } |
35 | |
36 | return $status; |
37 | } |
38 | |
39 | } |