MDL-42389 Restore: Broken restore causes notice before exception
authorsam marshall <s.marshall@open.ac.uk>
Wed, 16 Oct 2013 11:13:31 +0000 (12:13 +0100)
committersam marshall <s.marshall@open.ac.uk>
Fri, 18 Oct 2013 11:00:56 +0000 (12:00 +0100)
backup/util/dbops/restore_dbops.class.php

index 0d0155d..a1aafb8 100644 (file)
@@ -882,9 +882,11 @@ abstract class restore_dbops {
             $newcontextid = $forcenewcontextid;
         } else {
             // Get new context, must exist or this will fail
-            if (!$newcontextid = self::get_backup_ids_record($restoreid, 'context', $oldcontextid)->newitemid) {
+            $newcontextrecord = self::get_backup_ids_record($restoreid, 'context', $oldcontextid);
+            if (!$newcontextrecord || !$newcontextrecord->newitemid) {
                 throw new restore_dbops_exception('unknown_context_mapping', $oldcontextid);
             }
+            $newcontextid = $newcontextrecord->newitemid;
         }
 
         // Sometimes it's possible to have not the oldcontextids stored into backup_ids_temp->parentitemid