forked from science-ation/science-ation
- 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:
parent
2715d67aef
commit
190adc2a6d
@ -1,31 +1,34 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
/* This file may contain 2 functions, a db_update_pre() and a db_update_post()
|
/* This file may contain 2 functions, a db_update_$ver_pre() and a
|
||||||
* db_update_pre() is called before the SQL patch is applied, and as expected,
|
* db_update_$ver_post(). _pre() is called before the SQL patch is
|
||||||
* db_update_post() is called after.
|
*applied, and as expected, _post() is called after.
|
||||||
*
|
*
|
||||||
* These functions are called from the main db_update.php file, and included
|
* 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
|
* 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
|
* 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
|
* 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();
|
$update_62_committee = array();
|
||||||
function db_update_pre()
|
function db_update_62_pre()
|
||||||
{
|
{
|
||||||
global $committee;
|
global $update_62_committee;
|
||||||
$q = mysql_query("SELECT * FROM committees_members");
|
$q = mysql_query("SELECT * FROM committees_members");
|
||||||
while($r = mysql_fetch_assoc($q)) {
|
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;
|
global $config;
|
||||||
|
|
||||||
foreach($committee as $c) {
|
foreach($update_62_committee as $c) {
|
||||||
list($fn, $ln) = split(' ', $c['name'], 2);
|
list($fn, $ln) = split(' ', $c['name'], 2);
|
||||||
$username = $c['email'];
|
$username = $c['email'];
|
||||||
$fn = mysql_escape_string($fn);
|
$fn = mysql_escape_string($fn);
|
||||||
|
@ -59,10 +59,10 @@ if($dbcodeversion && $dbdbversion)
|
|||||||
{
|
{
|
||||||
include("db.update.$ver.php");
|
include("db.update.$ver.php");
|
||||||
}
|
}
|
||||||
if(is_callable("db_update_pre")) {
|
if(is_callable("db_update_{$ver}_pre")) {
|
||||||
echo "db.update.$ver.php::db_update_pre() exists - running...\n";
|
echo "db.update.$ver.php::db_update_{$ver}_pre() exists - running...\n";
|
||||||
call_user_func("db_update_pre");
|
call_user_func("db_update_{$ver}_pre");
|
||||||
echo "db.update.$ver.php::db_update_pre() done.\n";
|
echo "db.update.$ver.php::db_update_{$ver}_pre() done.\n";
|
||||||
}
|
}
|
||||||
if(file_exists("db.update.$ver.sql"))
|
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";
|
echo "Version $ver SQL update file not found - skipping over\n";
|
||||||
}
|
}
|
||||||
if(is_callable("db_update_post")) {
|
if(is_callable("db_update_{$ver}_post")) {
|
||||||
echo "db.update.$ver.php::db_update_post() exists - running...\n";
|
echo "db.update.$ver.php::db_update_{$ver}_post() exists - running...\n";
|
||||||
call_user_func("db_update_post");
|
call_user_func("db_update_{$ver}_post");
|
||||||
echo "db.update.$ver.php::db_update_post() done.\n";
|
echo "db.update.$ver.php::db_update_{$ver}_post() done.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "\nAll done - updating new DB version to $dbcodeversion\n";
|
echo "\nAll done - updating new DB version to $dbcodeversion\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user