- Update the way php scripts are called.. we need to avoid collisions if the

updater runs in a loop.
- Fix the 62 update script to use the new format
This commit is contained in:
dave 2007-11-18 08:01:05 +00:00
parent 2715d67aef
commit 190adc2a6d
2 changed files with 22 additions and 19 deletions

View File

@ -1,31 +1,34 @@
<?
/* This file may contain 2 functions, a db_update_pre() and a db_update_post()
* db_update_pre() is called before the SQL patch is applied, and as expected,
* db_update_post() is called after.
/* This file may contain 2 functions, a db_update_$ver_pre() and a
* db_update_$ver_post(). _pre() is called before the SQL patch is
*applied, and as expected, _post() is called after.
*
* These functions are called from the main db_update.php file, and included
* once, so any global variables declared in here WILL REMAIN across both
* calls. meaning you can pull some stuff out of the database in _pre(), and
* then the patch will be applied, and they it can be inserted back into the
* database in _post(). */
* database in _post().
* Also note that MULTIPLE php scripts could be included if the db update is
* large, so global variable names probably shouldn't conflict... put the version
* number in them*/
$committee = array();
function db_update_pre()
$update_62_committee = array();
function db_update_62_pre()
{
global $committee;
global $update_62_committee;
$q = mysql_query("SELECT * FROM committees_members");
while($r = mysql_fetch_assoc($q)) {
$committee[] = $r;
$update_62_committee[] = $r;
}
}
function db_update_post()
function db_update_62_post()
{
global $committee;
global $update_62_committee;
global $config;
foreach($committee as $c) {
foreach($update_62_committee as $c) {
list($fn, $ln) = split(' ', $c['name'], 2);
$username = $c['email'];
$fn = mysql_escape_string($fn);

View File

@ -59,10 +59,10 @@ if($dbcodeversion && $dbdbversion)
{
include("db.update.$ver.php");
}
if(is_callable("db_update_pre")) {
echo "db.update.$ver.php::db_update_pre() exists - running...\n";
call_user_func("db_update_pre");
echo "db.update.$ver.php::db_update_pre() done.\n";
if(is_callable("db_update_{$ver}_pre")) {
echo "db.update.$ver.php::db_update_{$ver}_pre() exists - running...\n";
call_user_func("db_update_{$ver}_pre");
echo "db.update.$ver.php::db_update_{$ver}_pre() done.\n";
}
if(file_exists("db.update.$ver.sql"))
{
@ -75,10 +75,10 @@ if($dbcodeversion && $dbdbversion)
{
echo "Version $ver SQL update file not found - skipping over\n";
}
if(is_callable("db_update_post")) {
echo "db.update.$ver.php::db_update_post() exists - running...\n";
call_user_func("db_update_post");
echo "db.update.$ver.php::db_update_post() done.\n";
if(is_callable("db_update_{$ver}_post")) {
echo "db.update.$ver.php::db_update_{$ver}_post() exists - running...\n";
call_user_func("db_update_{$ver}_post");
echo "db.update.$ver.php::db_update_{$ver}_post() done.\n";
}
}
echo "\nAll done - updating new DB version to $dbcodeversion\n";