summaryrefslogtreecommitdiff
path: root/includes/install.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-13 23:07:16 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-13 23:07:16 +0000
commit0ac67018a337f02cf5272e5486eb0bacad6aeac7 (patch)
tree4803e62b1db0aa6c5e307ebcae151793f485a258 /includes/install.inc
parenta3fab0edade68b9748d40b04bc7b48ee69b7fe3e (diff)
downloadbrdo-0ac67018a337f02cf5272e5486eb0bacad6aeac7.tar.gz
brdo-0ac67018a337f02cf5272e5486eb0bacad6aeac7.tar.bz2
#946968 follow-up by Damien Tournoud: Refactor version check for databases.
Diffstat (limited to 'includes/install.inc')
-rw-r--r--includes/install.inc31
1 files changed, 27 insertions, 4 deletions
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.