Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-30456' of git://github.com/stronk7/moodle

  • Loading branch information...
commit 66d8f36b9e2d7e15ae20a1c00dc2e6a855f3b752 2 parents 77da06c + ef77af3
@stronk7 stronk7 authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 backup/moodle2/backup_stepslib.php
View
15 backup/moodle2/backup_stepslib.php
@@ -1114,14 +1114,12 @@ protected function define_structure() {
$user->set_source_sql('SELECT u.*, c.id AS contextid, m.wwwroot AS mnethosturl
FROM {user} u
JOIN {backup_ids_temp} bi ON bi.itemid = u.id
- JOIN {context} c ON c.instanceid = u.id
+ LEFT JOIN {context} c ON c.instanceid = u.id AND c.contextlevel = ' . CONTEXT_USER . '
LEFT JOIN {mnet_host} m ON m.id = u.mnethostid
WHERE bi.backupid = ?
- AND bi.itemname = ?
- AND c.contextlevel = ?', array(
+ AND bi.itemname = ?', array(
backup_helper::is_sqlparam($this->get_backupid()),
- backup_helper::is_sqlparam('userfinal'),
- backup_helper::is_sqlparam(CONTEXT_USER)));
+ backup_helper::is_sqlparam('userfinal')));
// All the rest on information is only added if we arent
// in an anonymized backup
@@ -1772,12 +1770,15 @@ protected function define_execution() {
'backupid' => $this->get_backupid(), 'itemname' => 'userfinal'));
foreach ($rs as $record) {
$userid = $record->itemid;
- $userctxid = get_context_instance(CONTEXT_USER, $userid)->id;
+ $userctx = get_context_instance(CONTEXT_USER, $userid);
+ if (!$userctx) {
+ continue; // User has not context, sure it's a deleted user, so cannot have files
+ }
// Proceed with every user filearea
foreach ($fileareas as $filearea) {
// We don't need to specify itemid ($userid - 5th param) as far as by
// context we can get all the associated files. See MDL-22092
- backup_structure_dbops::annotate_files($this->get_backupid(), $userctxid, 'user', $filearea, null);
+ backup_structure_dbops::annotate_files($this->get_backupid(), $userctx->id, 'user', $filearea, null);
}
}
$rs->close();
Please sign in to comment.
Something went wrong with that request. Please try again.