Page MenuHomePhabricator

SQLite: don't always autocreate DB and its directory
Closed, ResolvedPublic

Description

Currently $wgSQLiteDataDir is created not only by installer, but also by DatabaseSqlite::__construct, and the database file is silently created if it does not exists, which leads to a few problems:

  1. If $wgSQLiteDataDir is empty, the directory defaults to dirname($_SERVER['DOCUMENT_ROOT']).'/data'. However, if MediaWiki is not installed in the document root, the data directory will be different for web scripts and command line maintenance scripts, which will fail with cryptic SQL errors.
  2. If the database file is inaccessible to MW post-install, it will be transparently recreated and pageviews will result in SQL error messages. An equivalent of MySQL's "Can't contact database server" would be much more appropriate.

So my proposal is to check DB file accessibility in DatabaseSqlite constructor, and throw exceptions instead of creating useless empty databases. This should also result in deprecation $wgSQLiteDataDirMode, as this value should and needs to be specified by user during installation once and forever.


Version: 1.16.x
Severity: enhancement

Details

Reference
bz20260