diff options
-rw-r--r-- | includes/bootstrap.inc | 15 | ||||
-rw-r--r-- | includes/database/mysql/install.inc | 7 | ||||
-rw-r--r-- | includes/database/pgsql/install.inc | 4 | ||||
-rw-r--r-- | includes/database/sqlite/install.inc | 11 | ||||
-rw-r--r-- | includes/install.inc | 31 |
5 files changed, 41 insertions, 27 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index e332e01b4..833d3e0b8 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -27,21 +27,6 @@ define('DRUPAL_MINIMUM_PHP', '5.2.4'); define('DRUPAL_MINIMUM_PHP_MEMORY_LIMIT', '32M'); /** - * Minimum supported version of MySQL, if it is used. - */ -define('DRUPAL_MINIMUM_MYSQL', '5.0.15'); - -/** - * Minimum supported version of PostgreSQL, if it is used. - */ -define('DRUPAL_MINIMUM_PGSQL', '8.3'); - -/** - * Minimum supported version of SQLite, if it is used. - */ -define('DRUPAL_MINIMUM_SQLITE', '3.3.7'); - -/** * Indicates that the item should never be removed unless explicitly selected. * * The item may be removed using cache_clear_all() with a cache ID. diff --git a/includes/database/mysql/install.inc b/includes/database/mysql/install.inc index 6965cb440..e0a3b510e 100644 --- a/includes/database/mysql/install.inc +++ b/includes/database/mysql/install.inc @@ -10,7 +10,6 @@ * Specifies installation tasks for MySQL and equivalent databases. */ class DatabaseTasks_mysql extends DatabaseTasks { - /** * The PDO driver name for MySQL and equivalent databases. * @@ -26,10 +25,10 @@ class DatabaseTasks_mysql extends DatabaseTasks { } /** - * Returns the minimum version for mysql. + * Returns the minimum version for MySQL. */ - protected function minimumVersion() { - return DRUPAL_MINIMUM_MYSQL; + public function minimumVersion() { + return '5.0.15'; } } diff --git a/includes/database/pgsql/install.inc b/includes/database/pgsql/install.inc index 1ff69580e..65a50061f 100644 --- a/includes/database/pgsql/install.inc +++ b/includes/database/pgsql/install.inc @@ -31,8 +31,8 @@ class DatabaseTasks_pgsql extends DatabaseTasks { return 'PostgreSQL'; } - protected function minimumVersion() { - return DRUPAL_MINIMUM_PGSQL; + public function minimumVersion() { + return '8.3'; } /** diff --git a/includes/database/sqlite/install.inc b/includes/database/sqlite/install.inc index 07ce754f0..a872bc74d 100644 --- a/includes/database/sqlite/install.inc +++ b/includes/database/sqlite/install.inc @@ -8,11 +8,18 @@ class DatabaseTasks_sqlite extends DatabaseTasks { protected $pdoDriver = 'sqlite'; + public function name() { return 'SQLite'; } - protected function minimumVersion() { - return DRUPAL_MINIMUM_SQLITE; + + /** + * Minimum engine version. + * + * @todo: consider upping to 3.6.8 in Drupal 8 to get SAVEPOINT support. + */ + public function minimumVersion() { + return '3.3.7'; } } diff --git a/includes/install.inc b/includes/install.inc index fd3ce35fb..5f16c018b 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -277,6 +277,10 @@ abstract class DatabaseTasks { */ protected $tasks = array( array( + 'function' => 'checkEngineVersion', + 'arguments' => array(), + ), + array( 'arguments' => array( 'CREATE TABLE drupal_install_test (id int NULL)', 'Drupal can use CREATE TABLE database commands.', @@ -348,8 +352,21 @@ abstract class DatabaseTasks { return $this->hasPdoDriver() && empty($this->error); } + /** + * Return the human-readable name of the driver. + */ abstract public function name(); - abstract protected function minimumVersion(); + + /** + * Return the minimum required version of the engine. + * + * @return + * A version string. If not NULL, it will be checked against the version + * reported by the Database engine using version_compare(). + */ + public function minimumVersion() { + return NULL; + } /** * Run database tasks and tests to see if Drupal can run on the database. @@ -357,9 +374,6 @@ abstract class DatabaseTasks { public function runTasks() { // We need to establish a connection before we can run tests. if ($this->connect()) { - if (version_compare(Database::getConnection()->version(), $this->minimumVersion()) < 0) { - throw new DatabaseTaskException(st("The database version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()))); - } foreach ($this->tasks as $task) { if (!isset($task['function'])) { $task['function'] = 'runTestQuery'; @@ -419,6 +433,15 @@ abstract class DatabaseTasks { return !$fatal; } } + + /** + * Check the engine version. + */ + protected function checkEngineVersion() { + if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion(), '<')) { + $this->fail(st("The database version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()))); + } + } } /** * @class Exception class used to throw error if the DatabaseInstaller fails. |