diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-18 00:46:54 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-18 00:46:54 +0000 |
commit | 5a06233304a9965c8319ec5c1fcc4fd582393d02 (patch) | |
tree | c70268e7920779f890ad3858c39b1ed2b0fa1623 /engine/lib/deprecated-1.8.php | |
parent | 5ee52a817885e641a56eef6ebcdd4250ef8be4b5 (diff) | |
download | elgg-5a06233304a9965c8319ec5c1fcc4fd582393d02.tar.gz elgg-5a06233304a9965c8319ec5c1fcc4fd582393d02.tar.bz2 |
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
Diffstat (limited to 'engine/lib/deprecated-1.8.php')
-rw-r--r-- | engine/lib/deprecated-1.8.php | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 76abc5c95..3f65fb58e 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -3808,7 +3808,7 @@ function register_metadata_url_handler($function, $extender_name = "all") { } /** - * + * * @deprecated 1.8 Use {@link elgg_register_relationship_url_handler()} */ function register_relationship_url_handler($function_name, $relationship_type = "all") { @@ -4335,3 +4335,71 @@ function display_widget(ElggObject $widget) { elgg_deprecated_notice("display_widget() was been deprecated. Use elgg_view_entity().", 1.8); return elgg_view_entity($widget); } + + +/** + * 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 + * @deprecated 1.8 Use PHP upgrades for sql changes. + */ +function db_upgrade($version, $fromdir = "", $quiet = FALSE) { + global $CONFIG; + + elgg_deprecated_notice('db_upgrade() is deprecated by using PHP upgrades.', 1.8); + + $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; +}
\ No newline at end of file |