From 7b51c4e134013bd818a1f84e7de78b3fc0d86df8 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 11 Dec 2007 15:55:25 +0000 Subject: [PATCH] MDL-12542 - backup_todb not called on restore on date before it is inserted into mdl_user. This would cause a backup from a pre 1.7 site (or a pre 1.7 that has been upgraded to 1.9) to a 1.9 fresh install, to fail sometimes. Merged from MOODLE_19_STABLE. --- backup/restorelib.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index 91683ada9a0..9b210841175 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2234,7 +2234,7 @@ echo '

Updating config for block ', $instance->id, '.

'; //in backup_ids->info will be the real info (serialized) $info = restore_read_xml_users($restore,$xml_file); } - + //Now, get evey user_id from $info and user data from $backup_ids //and create the necessary records (users, user_students, user_teachers //user_course_creators and user_admins @@ -2248,6 +2248,14 @@ echo '

Updating config for block ', $instance->id, '.

'; foreach ($info->users as $userid) { $rec = backup_getid($restore->backup_unique_code,"user",$userid); $user = $rec->info; + foreach (array_keys(get_object_vars($user)) as $field) { + if (!is_array($user->$field)) { + $user->$field = backup_todb($user->$field); + if (is_null($user->$field)) { + $user->$field = ''; + } + } + } //Now, recode some languages (Moodle 1.5) if ($user->lang == 'ma_nt') { @@ -2326,7 +2334,7 @@ echo '

Updating config for block ', $instance->id, '.

'; //Unset the id because it's going to be inserted with a new one unset ($user->id); // relink the descriptions - $user->description = stripslashes(backup_todb($user->description)); + $user->description = stripslashes($user->description); if (!empty($CFG->disableuserimages)) { $user->picture = 0; @@ -2362,6 +2370,7 @@ echo '

Updating config for block ', $instance->id, '.

'; //We are going to create the user //The structure is exactly as we need + $newid = insert_record ("user", addslashes_recursive($user)); //Put the new id $status = backup_putid($restore->backup_unique_code,"user",$userid,$newid,"new");