]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11507, MDL-15157 database activity - avoid some notices on restore ; merged from...
authorEloy Lafuente <stronk7@moodle.org>
Fri, 18 Dec 2009 17:53:47 +0000 (17:53 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Fri, 18 Dec 2009 17:53:47 +0000 (17:53 +0000)
mod/data/restorelib.php

index 096c5fbc9e26bf18be8d9fb50092bfd14e8d9933..3079a0c5a80f52e744ac0706fc7f6510a3d2be9f 100644 (file)
@@ -230,7 +230,11 @@ function data_records_restore_mods ($old_data_id, $new_data_id, $info, $restore)
 
     $status = true;
 
-    $records = $info['MOD']['#']['RECORDS']['0']['#']['RECORD'];
+    $records = isset($info['MOD']['#']['RECORDS']['0']['#']['RECORD']) ? $info['MOD']['#']['RECORDS']['0']['#']['RECORD'] : array();
+
+    if (empty($records)) { // no records to restore
+        return true;
+    }
 
     for ($i = 0; $i < sizeof($records); $i++) {
 
@@ -387,7 +391,7 @@ function data_ratings_restore_mods ($oldid, $newid, $info, $rec_info) {
 
     $status = true;
 
-    $ratings= $rec_info['#']['RATINGS']['0']['#']['RATING'];
+    $ratings= isset($rec_info['#']['RATINGS']['0']['#']['RATING']) ? $rec_info['#']['RATINGS']['0']['#']['RATING'] : array();
 
     if (empty($ratings)) { // no ratings to restore
         return true;
@@ -412,7 +416,7 @@ function data_comments_restore_mods ($oldid, $newid, $old_data_id, $new_data_id,
 
     $newmodcontext = restore_get_new_context($restore, 'course_modules', CONTEXT_MODULE, $old_gid);
 
-    $comments= $rec_info['#']['COMMENTS']['0']['#']['COMMENT'];
+    $comments= isset($rec_info['#']['COMMENTS']['0']['#']['COMMENT']) ? $rec_info['#']['COMMENTS']['0']['#']['COMMENT'] : array();
 
     if (empty($comments)) { // no comments to restore
         return true;