Skip to content

Commit

Permalink
MDL-16879 Backup & mnet: Avoid problems in sites missing mnet_host re…
Browse files Browse the repository at this point in the history
…cords being more flexible in backup (outer join). Merged from 19_STABLE
  • Loading branch information
stronk7 committed Nov 16, 2008
1 parent d44d02a commit 2dc880c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backup/backuplib.php
Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 2dc880c

Please sign in to comment.