Browse Source

Avoid weird buffering situations where file is sent broken/incomplete for download - refs BT#13629

Angel Fernando Quiroz Campos 7 years ago
parent
commit
472544e585
2 changed files with 11 additions and 0 deletions
  1. 10 0
      main/inc/lib/document.lib.php
  2. 1 0
      main/inc/lib/usergroup.lib.php

+ 10 - 0
main/inc/lib/document.lib.php

@@ -353,6 +353,11 @@ class DocumentManager
             header('Content-Description: '.$filename);
             header('Content-Transfer-Encoding: binary');
 
+            if (function_exists('ob_end_clean')) {
+                // Use ob_end_clean() to avoid weird buffering situations where file is sent broken/incomplete for download
+                ob_end_clean();
+            }
+
             $res = fopen($full_file_name, 'r');
             fpassthru($res);
 
@@ -414,6 +419,11 @@ class DocumentManager
                 );
                 echo $content;
             } else {
+                if (function_exists('ob_end_clean')) {
+                    // Use ob_end_clean() to avoid weird buffering situations where file is sent broken/incomplete for download
+                    ob_end_clean();
+                }
+
                 readfile($full_file_name);
             }
 

+ 1 - 0
main/inc/lib/usergroup.lib.php

@@ -799,6 +799,7 @@ class UserGroup extends Model
         $current_list = self::get_users_by_usergroup($usergroup_id);
         $course_list = self::get_courses_by_usergroup($usergroup_id);
         $session_list = self::get_sessions_by_usergroup($usergroup_id);
+        $session_list =  array_filter($session_list);
         $relationType = (int) $relationType;
 
         $delete_items = [];