Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcmail_install.php')
-rw-r--r--program/include/rcmail_install.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php
index ae5a6bcbd..ebd23417d 100644
--- a/program/include/rcmail_install.php
+++ b/program/include/rcmail_install.php
@@ -463,9 +463,23 @@ class rcmail_install
// read reference schema from mysql.initial.sql
$engine = $db->db_provider;
- $db_schema = $this->db_read_schema(INSTALL_PATH . "SQL/$engine.initial.sql");
+ $db_schema = $this->db_read_schema(INSTALL_PATH . "SQL/$engine.initial.sql", $schema_version);
$errors = array();
+ // Just check the version
+ if ($schema_version) {
+ $version = rcmail_utils::db_version();
+
+ if (empty($version)) {
+ $errors[] = "Schema version not found";
+ }
+ else if ($schema_version != $version) {
+ $errors[] = "Schema version: {$version} (required: {$schema_version})";
+ }
+
+ return !empty($errors) ? $errors : false;
+ }
+
// check list of tables
$existing_tables = $db->list_tables();
@@ -491,7 +505,7 @@ class rcmail_install
/**
* Utility function to read database schema from an .sql file
*/
- private function db_read_schema($schemafile)
+ private function db_read_schema($schemafile, &$version = null)
{
$lines = file($schemafile);
$schema = array();
@@ -503,6 +517,9 @@ class rcmail_install
$table_name = end($table_name);
$table_name = preg_replace('/[`"\[\]]/', '', $table_name);
}
+ else if (preg_match('/insert into/i', $line) && preg_match('/\'roundcube-version\',\s*\'([0-9]+)\'/', $line, $m)) {
+ $version = $m[1];
+ }
else if ($table_name && ($line = trim($line))) {
if ($line == 'GO' || $line[0] == ')' || $line[strlen($line)-1] == ';') {
$table_name = null;