From 5a06233304a9965c8319ec5c1fcc4fd582393d02 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 18 Feb 2011 00:46:54 +0000 Subject: Fixes #1433, #2183. Upgrades are now tracked and will be run if needed regardless of version. git-svn-id: http://code.elgg.org/elgg/trunk@8277 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 64 ------------------------------------------------- 1 file changed, 64 deletions(-) (limited to 'engine/lib/database.php') diff --git a/engine/lib/database.php b/engine/lib/database.php index b2cc5ca29..fa5b4a894 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -628,70 +628,6 @@ function run_sql_script($scriptlocation) { } } -/** - * Upgrade the database schema in an ordered sequence. - * - * Executes all upgrade files in elgg/engine/schema/upgrades/ in sequential order. - * Upgrade files must be in the standard Elgg release format of YYYYMMDDII.sql - * where II is an incrementor starting from 01. - * - * Files that are < $version will be ignored. - * - * @warning Plugin authors should not call this function directly. - * - * @param int $version The version you are upgrading from in the format YYYYMMDDII. - * @param string $fromdir Optional directory to load upgrades from. default: engine/schema/upgrades/ - * @param bool $quiet If true, suppress all error messages. Only use for the upgrade from <=1.6. - * - * @return bool - * @see upgrade.php - * @see version.php - */ -function db_upgrade($version, $fromdir = "", $quiet = FALSE) { - global $CONFIG; - - $version = (int) $version; - - if (!$fromdir) { - $fromdir = $CONFIG->path . 'engine/schema/upgrades/'; - } - - if ($handle = opendir($fromdir)) { - $sqlupgrades = array(); - - while ($sqlfile = readdir($handle)) { - if (!is_dir($fromdir . $sqlfile)) { - if (preg_match('/^([0-9]{10})\.(sql)$/', $sqlfile, $matches)) { - $sql_version = (int) $matches[1]; - if ($sql_version > $version) { - $sqlupgrades[] = $sqlfile; - } - } - } - } - - asort($sqlupgrades); - - if (sizeof($sqlupgrades) > 0) { - foreach ($sqlupgrades as $sqlfile) { - - // hide all errors. - if ($quiet) { - try { - run_sql_script($fromdir . $sqlfile); - } catch (DatabaseException $e) { - error_log($e->getmessage()); - } - } else { - run_sql_script($fromdir . $sqlfile); - } - } - } - } - - return TRUE; -} - /** * Sanitise a string for database use, but with the option of escaping extra characters. * -- cgit v1.2.3