MDL-28221 resource: improved file not found handling
authorDavid Mudrak <david@moodle.com>
Mon, 11 Jul 2011 10:12:38 +0000 (12:12 +0200)
committerDavid Mudrak <david@moodle.com>
Mon, 11 Jul 2011 21:30:28 +0000 (23:30 +0200)
When the referenced file is not found, do not rely on the record in
resource_old as the resource can be actually restored from a 1.9 backup.

mod/resource/locallib.php

index 7690c2c..41b77cc 100644 (file)
@@ -345,7 +345,11 @@ function resource_print_filenotfound($resource, $cm, $course) {
     resource_print_header($resource, $cm, $course);
     resource_print_heading($resource, $cm, $course);
     resource_print_intro($resource, $cm, $course);
-    echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resource_old->type));
+    if ($resource_old) {
+        echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resource_old->type));
+    } else {
+        echo $OUTPUT->notification(get_string('filenotfound', 'resource'));
+    }
     echo $OUTPUT->footer();
     die;
 }