1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* SQLite specific install functions
|
6
|
*/
|
7
|
|
8
|
class DatabaseTasks_sqlite extends DatabaseTasks {
|
9
|
protected $pdoDriver = 'sqlite';
|
10
|
|
11
|
public function name() {
|
12
|
return st('SQLite');
|
13
|
}
|
14
|
|
15
|
/**
|
16
|
* Minimum engine version.
|
17
|
*
|
18
|
* @todo: consider upping to 3.6.8 in Drupal 8 to get SAVEPOINT support.
|
19
|
*/
|
20
|
public function minimumVersion() {
|
21
|
return '3.3.7';
|
22
|
}
|
23
|
|
24
|
public function getFormOptions($database) {
|
25
|
$form = parent::getFormOptions($database);
|
26
|
|
27
|
// Remove the options that only apply to client/server style databases.
|
28
|
unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);
|
29
|
|
30
|
// Make the text more accurate for SQLite.
|
31
|
$form['database']['#title'] = st('Database file');
|
32
|
$form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
|
33
|
$default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
|
34
|
$form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
|
35
|
return $form;
|
36
|
}
|
37
|
|
38
|
public function validateDatabaseSettings($database) {
|
39
|
// Perform standard validation.
|
40
|
$errors = parent::validateDatabaseSettings($database);
|
41
|
|
42
|
// Verify the database is writable.
|
43
|
$db_directory = new SplFileInfo(dirname($database['database']));
|
44
|
if (!$db_directory->isWritable()) {
|
45
|
$errors[$database['driver'] . '][database'] = st('The directory you specified is not writable by the web server.');
|
46
|
}
|
47
|
|
48
|
return $errors;
|
49
|
}
|
50
|
}
|
51
|
|