]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16879 Backup & mnet: Avoid problems in sites missing mnet_host records being...
authorstronk7 <stronk7>
Sun, 16 Nov 2008 23:24:32 +0000 (23:24 +0000)
committerstronk7 <stronk7>
Sun, 16 Nov 2008 23:24:32 +0000 (23:24 +0000)
backup/backuplib.php

index 4d97673565b2f7a0923ed8b8b472f568d102e157..314acd5e3c42af68999d6f1c48530f28614d94b0 100644 (file)
 
         // 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));
 
                 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));