145 if ( is_dir( $dir ) ) {
146 if ( !is_readable( $dir ) ) {
147 return Status::newFatal(
'config-sqlite-dir-unwritable', $dir );
151 if ( !is_writable( dirname( $dir ) ) ) {
153 if ( $webserverGroup !==
null ) {
154 return Status::newFatal(
155 'config-sqlite-parent-unwritable-group',
156 $dir, dirname( $dir ), basename( $dir ),
161 'config-sqlite-parent-unwritable-nogroup',
162 $dir, dirname( $dir ), basename( $dir )
225 $dir = $this->getVar(
'wgSQLiteDataDir' );
227 # Sanity check (Only available in web installation). We checked this before but maybe someone
228 # deleted the data dir between then and now
229 $dir_status = self::checkDataDir( $dir );
230 if ( $dir_status->isGood() ) {
231 $res = self::createDataDir( $dir );
232 if ( !
$res->isGood() ) {
239 $db = $this->getVar(
'wgDBname' );
241 # Make the main and cache stub DB files
242 $status = Status::newGood();
243 $status->merge( $this->makeStubDBFile( $dir, $db ) );
244 $status->merge( $this->makeStubDBFile( $dir,
"wikicache" ) );
245 $status->merge( $this->makeStubDBFile( $dir,
"{$db}_l10n_cache" ) );
246 $status->merge( $this->makeStubDBFile( $dir,
"{$db}_jobqueue" ) );
247 if ( !$status->isOK() ) {
251 # Nuke the unused settings for clarity
252 $this->setVar(
'wgDBserver',
'' );
253 $this->setVar(
'wgDBuser',
'' );
254 $this->setVar(
'wgDBpassword',
'' );
255 $this->setupSchemaVars();
257 # Create the l10n cache DB
259 $conn = Database::factory(
260 'sqlite', [
'dbname' =>
"{$db}_l10n_cache",
'dbDirectory' => $dir ] );
261 # @todo: don't duplicate l10n_cache definition, though it's very simple
264 CREATE TABLE l10n_cache (
265 lc_lang BLOB NOT NULL,
266 lc_key TEXT NOT NULL,
267 lc_value BLOB NOT NULL,
268 PRIMARY KEY (lc_lang, lc_key)
271 $conn->query( $sql, __METHOD__ );
272 $conn->query(
"PRAGMA journal_mode=WAL", __METHOD__ );
273 $conn->close( __METHOD__ );
275 return Status::newFatal(
'config-sqlite-connection-error', $e->getMessage() );
278 # Create the job queue DB
280 $conn = Database::factory(
281 'sqlite', [
'dbname' =>
"{$db}_jobqueue",
'dbDirectory' => $dir ] );
282 # @todo: don't duplicate job definition, though it's very static
286 job_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
287 job_cmd BLOB NOT NULL
default '',
288 job_namespace INTEGER NOT NULL,
289 job_title TEXT NOT NULL,
290 job_timestamp BLOB NULL
default NULL,
291 job_params BLOB NOT NULL,
292 job_random integer NOT NULL
default 0,
293 job_attempts integer NOT NULL
default 0,
294 job_token BLOB NOT NULL
default '',
295 job_token_timestamp BLOB NULL
default NULL,
296 job_sha1 BLOB NOT NULL
default ''
298 CREATE INDEX job_sha1 ON job (job_sha1);
299 CREATE INDEX job_cmd_token ON job (job_cmd,job_token,job_random);
300 CREATE INDEX job_cmd_token_id ON job (job_cmd,job_token,job_id);
301 CREATE INDEX job_cmd ON job (job_cmd, job_namespace, job_title, job_params);
302 CREATE INDEX job_timestamp ON job (job_timestamp);
304 $conn->query( $sql, __METHOD__ );
305 $conn->query(
"PRAGMA journal_mode=WAL", __METHOD__ );
306 $conn->close( __METHOD__ );
308 return Status::newFatal(
'config-sqlite-connection-error', $e->getMessage() );
312 return $this->getConnection();
359 $module = DatabaseSqlite::getFulltextSearchModule();
360 $searchIndexSql = (string)$this->db->selectField(
361 $this->db->addIdentifierQuotes(
'sqlite_master' ),
363 [
'tbl_name' => $this->db->tableName(
'searchindex',
'raw' ) ],
366 $fts3tTable = ( stristr( $searchIndexSql,
'fts' ) !== false );
368 if ( $fts3tTable && !$module ) {
369 $status->warning(
'config-sqlite-fts3-downgrade' );
370 $this->db->sourceFile(
"$IP/maintenance/sqlite/archives/searchindex-no-fts.sql" );
371 } elseif ( !$fts3tTable && $module ==
'FTS3' ) {
372 $this->db->sourceFile(
"$IP/maintenance/sqlite/archives/searchindex-fts3.sql" );