diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-01-10 21:21:11 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-01-10 21:21:11 +0000 |
commit | 4dcfd46b8b6e3bbe9c12493e744be04d8861684e (patch) | |
tree | 424b5dcb93bd68c87a022fb8d206932017b3d782 /engine/lib/database.php | |
parent | 80add6be750f65bea1108d306201b7f90ae5f88a (diff) | |
download | elgg-4dcfd46b8b6e3bbe9c12493e744be04d8861684e.tar.gz elgg-4dcfd46b8b6e3bbe9c12493e744be04d8861684e.tar.bz2 |
Fixes #1432: Version number is set during installation.
Refs #1424: The upgrade functions now detect if no version number is saved to the db and silences all upgrade warnings and errors. This is required for all installations < this commit to upgrade correctly because of #1432.
More strict regex for finding upgrade files.
Upgrade mysql.sql schema with latest.
git-svn-id: http://code.elgg.org/elgg/trunk@3791 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r-- | engine/lib/database.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php index 87b002508..262e651ee 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -518,9 +518,10 @@ function run_sql_script($scriptlocation) { * * @param int $version The version you are upgrading from (usually given in the Elgg version format of YYYYMMDDXX - see version.php for example) * @param string $fromdir Optional directory to load upgrades from (default: engine/schema/upgrades/) + * @param bool $quiet If true, will suppress all error messages. Don't use this. * @return bool */ -function db_upgrade($version, $fromdir = "") { +function db_upgrade($version, $fromdir = "", $quiet = FALSE) { global $CONFIG; // Elgg and its database must be installed to upgrade it! @@ -539,7 +540,7 @@ function db_upgrade($version, $fromdir = "") { while ($sqlfile = readdir($handle)) { if (!is_dir($fromdir . $sqlfile)) { - if (preg_match('/([0-9]*)\.sql/',$sqlfile,$matches)) { + if (preg_match('/^([0-9]{10})\.(sql)$/', $sqlfile, $matches)) { $sql_version = (int) $matches[1]; if ($sql_version > $version) { $sqlupgrades[] = $sqlfile; @@ -552,17 +553,22 @@ function db_upgrade($version, $fromdir = "") { if (sizeof($sqlupgrades) > 0) { foreach($sqlupgrades as $sqlfile) { -// let's not allow failing upgrade to pass. -// try { + + // hide all errors. + if ($quiet) { + try { + run_sql_script($fromdir . $sqlfile); + } catch (DatabaseException $e) { + error_log($e->getmessage()); + } + } else { run_sql_script($fromdir . $sqlfile); -// } catch (DatabaseException $e) { -// error_log($e->getmessage()); -// } + } } } } - return true; + return TRUE; } /** |