From: tjhunt <tjhunt> Date: Tue, 11 Dec 2007 15:55:25 +0000 (+0000) Subject: MDL-12542 - backup_todb not called on restore on date before it is inserted into... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7b51c4e134013bd818a1f84e7de78b3fc0d86df8;p=moodle.git 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. --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 91683ada9a..9b21084117 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2234,7 +2234,7 @@ echo '<p>Updating config for block ', $instance->id, '.</p>'; //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 '<p>Updating config for block ', $instance->id, '.</p>'; 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 '<p>Updating config for block ', $instance->id, '.</p>'; //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 '<p>Updating config for block ', $instance->id, '.</p>'; //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");