do not send stored file if nothing to send given
authorPetr Skoda <skodak@moodle.org>
Mon, 18 Oct 2010 11:39:57 +0000 (11:39 +0000)
committerPetr Skoda <skodak@moodle.org>
Mon, 18 Oct 2010 11:39:57 +0000 (11:39 +0000)
lib/filelib.php

index 7c4c8de..2cfa789 100644 (file)
@@ -1783,6 +1783,14 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
 function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownload=false, $filename=null, $dontdie=false) {
     global $CFG, $COURSE, $SESSION;
 
 function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownload=false, $filename=null, $dontdie=false) {
     global $CFG, $COURSE, $SESSION;
 
+    if (!$stored_file or $stored_file->is_directory()) {
+        // nothing to serve
+        if ($dontdie) {
+            return;
+        }
+        die;
+    }
+
     if ($dontdie) {
         ignore_user_abort(true);
     }
     if ($dontdie) {
         ignore_user_abort(true);
     }