From 2dc880c9999910834d6f479c35e8ba7e3b778827 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 16 Nov 2008 23:24:32 +0000 Subject: [PATCH] MDL-16879 Backup & mnet: Avoid problems in sites missing mnet_host records being more flexible in backup (outer join). Merged from 19_STABLE --- backup/backuplib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backup/backuplib.php b/backup/backuplib.php index 4d97673565b2f..314acd5e3c42a 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -1279,11 +1279,16 @@ function backup_user_info ($bf,$preferences) { // Use a recordset to for the memory handling on to // the DB and run faster + // Note the outer join with mnet_host: It shouldn't be neccesary + // but there are some sites having mnet_host records missing + // and that causes backup to fail (no users). Being a bit more + // flexible here (outer joing) we bypass the problem and doesn't + // cause more troubles. Eloy - MDL-16879 $users = $DB->get_recordset_sql("SELECT b.old_id, b.table_name, b.info, u.*, m.wwwroot FROM {backup_ids} b JOIN {user} u ON b.old_id=u.id - JOIN {mnet_host} m ON u.mnethostid=m.id + LEFT JOIN {mnet_host} m ON u.mnethostid=m.id WHERE b.backup_code = ? AND b.table_name = 'user'", array($preferences->backup_unique_code)); @@ -1340,7 +1345,7 @@ function backup_user_info ($bf,$preferences) { fwrite ($bf,full_tag("AJAX",4,false,$user->ajax)); fwrite ($bf,full_tag("AUTOSUBSCRIBE",4,false,$user->autosubscribe)); fwrite ($bf,full_tag("TRACKFORUMS",4,false,$user->trackforums)); - if ($user->mnethostid != $CFG->mnet_localhost_id) { + if ($user->mnethostid != $CFG->mnet_localhost_id && !empty($user->wwwroot)) { fwrite ($bf,full_tag("MNETHOSTURL",4,false,$user->wwwroot)); } fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$user->timemodified));