install.inc 1.7 KB

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