MediaWiki master
SqliteCreateSearchIndexTask.php
Go to the documentation of this file.
1<?php
2
4
7
15 public function getName() {
16 return 'search';
17 }
18
20 public function getDependencies() {
21 return [ 'tables' ];
22 }
23
24 public function execute(): Status {
25 $status = Status::newGood();
27 $module = DatabaseSqlite::getFulltextSearchModule();
28 $searchIndexSql = (string)$db->newSelectQueryBuilder()
29 ->select( 'sql' )
30 ->from( 'sqlite_master' )
31 ->where( [ 'tbl_name' => $db->tableName( 'searchindex', 'raw' ) ] )
32 ->caller( __METHOD__ )->fetchField();
33 $fts3tTable = ( stristr( $searchIndexSql, 'fts' ) !== false );
34
35 if ( $fts3tTable && !$module ) {
36 $status->warning( 'config-sqlite-fts3-downgrade' );
37 $status->merge( $this->applySourceFile( $db, 'searchindex-no-fts.sql' ) );
38 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
39 $status->merge( $this->applySourceFile( $db, 'searchindex-fts3.sql' ) );
40 }
41
42 return $status;
43 }
44
45}
getDependencies()
Get a list of names or aliases of tasks that must be done prior to this task.to override string|strin...
Base class for installer tasks.
Definition Task.php:24
definitelyGetConnection(string $type)
Get a database connection, and throw if a connection could not be obtained.
Definition Task.php:212
applySourceFile(IMaintainableDatabase $conn, string $relPath)
Apply a SQL source file to the database as part of running an installation step.
Definition Task.php:227
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
This is the SQLite database abstraction layer.
const CONN_CREATE_TABLES
A connection with a role suitable for creating tables.