Permalink
Browse files

MDL-12542 - backup_todb not called on restore on date before it is in…

…serted 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. Backported from MOODLE_19_STABLE.
  • Loading branch information...
1 parent 4520a06 commit fb18d9cab72309ac22db4fa46d36ec58bb0d77d4 tjhunt committed Dec 11, 2007
Showing with 10 additions and 2 deletions.
  1. +10 −2 backup/restorelib.php
View
@@ -1418,15 +1418,23 @@ function restore_create_users($restore,$xml_file) {
//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
if (!empty($info->users)) {
//For each user, take its info from backup_ids
foreach ($info->users as $userid) {
- $rec = backup_getid($restore->backup_unique_code,"user",$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') {

0 comments on commit fb18d9c

Please sign in to comment.