Skip to content

Commit

Permalink
MDL-33430 Set newcontextid and newitemid when sending file to the pool
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jun 21, 2012
1 parent 38ca2f1 commit 83b2cc5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions backup/util/dbops/restore_dbops.class.php
Expand Up @@ -850,17 +850,17 @@ public static function send_files_to_pool($basepath, $restoreid, $component, $fi

// itemname = null, we are going to match only by context, no need to use itemid (all them are 0)
if ($itemname == null) {
$sql = 'SELECT contextid, component, filearea, itemid, itemid AS newitemid, info
$sql = "SELECT id AS bftid, contextid, component, filearea, itemid, itemid AS newitemid, info
FROM {backup_files_temp}
WHERE backupid = ?
AND contextid = ?
AND component = ?
AND filearea = ?';
AND filearea = ?";
$params = array($restoreid, $oldcontextid, $component, $filearea);

// itemname not null, going to join with backup_ids to perform the old-new mapping of itemids
} else {
$sql = "SELECT f.contextid, f.component, f.filearea, f.itemid, i.newitemid, f.info
$sql = "SELECT f.id AS bftid, f.contextid, f.component, f.filearea, f.itemid, i.newitemid, f.info
FROM {backup_files_temp} f
JOIN {backup_ids_temp} i ON i.backupid = f.backupid
$parentitemctxmatchsql
Expand Down Expand Up @@ -925,6 +925,13 @@ public static function send_files_to_pool($basepath, $restoreid, $component, $fi
$fs->create_file_from_pathname($file_record, $backuppath);
}

// store the the new contextid and the new itemid in case we need to remap
// references to this file later
$DB->update_record('backup_files_temp', array(
'id' => $rec->bftid,
'newcontextid' => $newcontextid,
'newitemid' => $rec->newitemid), true);

} else {
// this is an alias - we can't create it yet so we stash it in a temp
// table and will let the final task to deal with it
Expand Down

0 comments on commit 83b2cc5

Please sign in to comment.