* @return Status
*/
public function openConnection() {
- global $wgSQLiteDataDir;
-
$status = Status::newGood();
$dir = $this->getVar( 'wgSQLiteDataDir' );
$dbName = $this->getVar( 'wgDBname' );
try {
# @todo FIXME: Need more sensible constructor parameters, e.g. single associative array
- # Setting globals kind of sucks
- $wgSQLiteDataDir = $dir;
- $db = DatabaseBase::factory( 'sqlite', [ 'dbname' => $dbName ] );
+ $db = Database::factory( 'sqlite', [ 'dbname' => $dbName, 'dbDirectory' => $dir ] );
$status->value = $db;
} catch ( DBConnectionError $e ) {
$status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
# Create the global cache DB
try {
- global $wgSQLiteDataDir;
- # @todo FIXME: setting globals kind of sucks
- $wgSQLiteDataDir = $dir;
- $conn = DatabaseBase::factory( 'sqlite', [ 'dbname' => "wikicache" ] );
+ $conn = Database::factory( 'sqlite', [ 'dbname' => 'wikicache', 'dbDirectory' => $dir ] );
# @todo: don't duplicate objectcache definition, though it's very simple
$sql =
<<<EOT
return $this->getConnection();
}
+ /**
+ * @param $dir
+ * @param $db
+ * @return Status
+ */
protected function makeStubDBFile( $dir, $db ) {
$file = DatabaseSqlite::generateFileName( $dir, $db );
if ( file_exists( $file ) ) {
'type' => 'sqlite',
'dbname' => 'wikicache',
'tablePrefix' => '',
+ 'dbDirectory' => \$wgSQLiteDataDir,
'flags' => 0
]
];";