From 02671df098baba66a4e7dcba836f126662a360cb Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 27 Apr 2008 01:49:44 +0000 Subject: [PATCH] Backporting from HEAD some recent improvements in order to be able to restore block instances properly. MDL-4934 --- backup/restorelib.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index ee446118dc4..7a76ec32c34 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -860,10 +860,22 @@ //Add this instance $instance->blockid = $blocks[$instance->name]->id; - - if ($newid = insert_record('block_instance', $instance)) { - if (!empty($instance->id)) { // this will only be set if we come from 1.7 and above backups - backup_putid ($restore->backup_unique_code,"block_instance",$instance->id,$newid); + + if (!empty($instance->id)) { + $oldid = $instance->id; + } else { + $oldid = 0; + } + + if ($instance->id = insert_record('block_instance', $instance)) { + // Create block instance + if (!$blockobj = block_instance($instance->name, $instance)) { + $status = false; + break; + } + // Save oldid after block restore process because info will be over-written with blank string + if ($oldid) { + backup_putid ($restore->backup_unique_code,"block_instance",$oldid,$instance->id); } } else { $status = false;