Merge branch 'MDL-66493-readstring_accel' of https://github.com/brendanheywood/moodle

This commit is contained in:
Jake Dallimore
2019-10-25 08:25:41 +08:00
3 changed files with 9 additions and 16 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ if (null !== $logid) {
header("Content-Disposition: attachment; filename=\"{$filename}\"");
}
readstring_accel($log->output, 'text/plain', false);
readstring_accel($log->output, 'text/plain');
exit;
}
+7 -15
View File
@@ -2250,10 +2250,10 @@ function readfile_accel($file, $mimetype, $accelerate) {
* Similar to readfile_accel() but designed for strings.
* @param string $string
* @param string $mimetype
* @param bool $accelerate
* @param bool $accelerate Ignored
* @return void
*/
function readstring_accel($string, $mimetype, $accelerate) {
function readstring_accel($string, $mimetype, $accelerate = false) {
global $CFG;
if ($mimetype === 'text/plain') {
@@ -2264,14 +2264,6 @@ function readstring_accel($string, $mimetype, $accelerate) {
}
header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
header('Accept-Ranges: none');
if ($accelerate and !empty($CFG->xsendfile)) {
$fs = get_file_storage();
if ($fs->xsendfile(sha1($string))) {
return;
}
}
header('Content-Length: '.strlen($string));
echo $string;
}
@@ -2320,7 +2312,7 @@ function send_temp_file($path, $filename, $pathisstring=false) {
// send the contents - we can not accelerate this because the file will be deleted asap
if ($pathisstring) {
readstring_accel($path, $mimetype, false);
readstring_accel($path, $mimetype);
} else {
readfile_accel($path, $mimetype, false);
@unlink($path);
@@ -2506,7 +2498,7 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
if (empty($filter)) {
// send the contents
if ($pathisstring) {
readstring_accel($path, $mimetype, !$dontdie);
readstring_accel($path, $mimetype);
} else {
readfile_accel($path, $mimetype, !$dontdie);
}
@@ -2526,7 +2518,7 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
}
$output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
readstring_accel($output, $mimetype, false);
readstring_accel($output, $mimetype);
} else if (($mimetype == 'text/plain') and ($filter == 1)) {
// only filter text if filter all files is selected
@@ -2542,12 +2534,12 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
}
$output = '<pre>'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'</pre>';
readstring_accel($output, $mimetype, false);
readstring_accel($output, $mimetype);
} else {
// send the contents
if ($pathisstring) {
readstring_accel($path, $mimetype, !$dontdie);
readstring_accel($path, $mimetype);
} else {
readfile_accel($path, $mimetype, !$dontdie);
}
+1
View File
@@ -69,6 +69,7 @@ validation against and defaults to null (so, no user needed) if not provided.
* The core_enrol_edit_user_enrolment webservice has been deprecated. Please use core_enrol_submit_user_enrolment_form instead.
* \single_button constructor has a new attributes param to add attributes to the button HTML tag.
* Improved url matching behaviour for profiled urls and excluded urls
* Attempting to use xsendfile via the 3rd param of readstring_accel() is now ignored.
=== 3.7 ===