From e2ed7b8eef8b0f9687767e33c6530b0ab98da5c2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 22 Oct 2006 16:46:41 +0000 Subject: - Patch #88705 by profix898 and sammys: made version checking work with PostgreSQL. (Critical bug) --- includes/database.mysql.inc | 18 ++++++++++++++---- includes/database.mysqli.inc | 21 +++++++++++++++------ includes/database.pgsql.inc | 33 +++++++++++++++++++-------------- 3 files changed, 48 insertions(+), 24 deletions(-) (limited to 'includes') diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc index 262a28c1c..b0ffd2692 100644 --- a/includes/database.mysql.inc +++ b/includes/database.mysql.inc @@ -18,21 +18,31 @@ function db_status_report($phase) { $t = get_t(); - $info = mysql_get_server_info(); + $version = db_version(); + $form['mysql'] = array( 'title' => $t('MySQL database'), - 'value' => ($phase == 'runtime') ? l($info, 'admin/logs/status/sql') : $info, + 'value' => ($phase == 'runtime') ? l($version, 'admin/logs/status/sql') : $version, ); - // Extract version number - list($version) = explode('-', $info); if (version_compare($version, DRUPAL_MINIMUM_MYSQL) < 0) { $form['mysql']['severity'] = REQUIREMENT_ERROR; $form['mysql']['description'] = $t('Your MySQL Server is too old. Drupal requires at least MySQL %version.', array('%version' => DRUPAL_MINIMUM_MYSQL)); } + return $form; } +/** + * Returns the version of the database server currently in use. + * + * @return Database server version + */ +function db_version() { + list($version) = explode('-', mysql_get_server_info()); + return $version; +} + /** * Initialize a database connection. * diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc index dd647165e..7cc5943b7 100644 --- a/includes/database.mysqli.inc +++ b/includes/database.mysqli.inc @@ -19,25 +19,34 @@ * Report database status. */ function db_status_report($phase) { - global $active_db; - $t = get_t(); - $info = mysqli_get_server_info($active_db); + $version = db_version(); + $form['mysql'] = array( 'title' => $t('MySQL database'), - 'value' => ($phase == 'runtime') ? l($info, 'admin/logs/status/sql') : $info, + 'value' => ($phase == 'runtime') ? l($version, 'admin/logs/status/sql') : $version, ); - // Extract version number - list($version) = explode('-', $info); if (version_compare($version, DRUPAL_MINIMUM_MYSQL) < 0) { $form['mysql']['severity'] = REQUIREMENT_ERROR; $form['mysql']['description'] = $t('Your MySQL Server is too old. Drupal requires at least MySQL %version.', array('%version' => DRUPAL_MINIMUM_MYSQL)); } + return $form; } +/** + * Returns the version of the database server currently in use. + * + * @return Database server version + */ +function db_version() { + global $active_db; + list($version) = explode('-', mysqli_get_server_info($active_db)); + return $version; +} + /** * Initialise a database connection. * diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc index f1500c8e8..b5b53b955 100644 --- a/includes/database.pgsql.inc +++ b/includes/database.pgsql.inc @@ -17,25 +17,30 @@ function db_status_report() { $t = get_t(); - $form['pgsql'] = array(); - - if (function_exists('pg_version')) { - $version = pg_version(); - if (version_compare($version['server'], DRUPAL_MINIMUM_PGSQL) < 0) { - $form['pgsql']['severity'] = REQUIREMENT_ERROR; - $form['pgsql']['description'] = $t('Your PostgreSQL Server is too old. Drupal requires at least PostgreSQL %version.', array('%version' => DRUPAL_MINIMUM_PGSQL)); - } - } - else { - $version = array('server' => $t('Unknown')); - } + $version = db_version(); - $form['pgsql']['title'] = $t('PostgreSQL database'); - $form['pgsql']['value'] = $version['server']; + $form['pgsql'] = array( + 'title' => $t('PostgreSQL database'), + 'value' => $version, + ); + + if (version_compare($version, DRUPAL_MINIMUM_PGSQL) < 0) { + $form['pgsql']['severity'] = REQUIREMENT_ERROR; + $form['pgsql']['description'] = $t('Your PostgreSQL Server is too old. Drupal requires at least PostgreSQL %version.', array('%version' => DRUPAL_MINIMUM_PGSQL)); + } return $form; } +/** + * Returns the version of the database server currently in use. + * + * @return Database server version + */ +function db_version() { + return db_result(db_query("SHOW SERVER_VERSION")); +} + /** * Initialize a database connection. * -- cgit v1.2.3