MDL-68342 files: Add a faster xsendfile method to avoid db lookups
This commit is contained in:
+1
-1
@@ -2169,7 +2169,7 @@ function readfile_accel($file, $mimetype, $accelerate) {
|
||||
if (is_object($file)) {
|
||||
$fs = get_file_storage();
|
||||
if ($fs->supports_xsendfile()) {
|
||||
if ($fs->xsendfile($file->get_contenthash())) {
|
||||
if ($fs->xsendfile_file($file)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1821,6 +1821,21 @@ class file_storage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve file content using X-Sendfile header.
|
||||
* Please make sure that all headers are already sent and the all
|
||||
* access control checks passed.
|
||||
*
|
||||
* This alternate method to xsendfile() allows an alternate file system
|
||||
* to use the full file metadata and avoid extra lookups.
|
||||
*
|
||||
* @param stored_file $file The file to send
|
||||
* @return bool success
|
||||
*/
|
||||
public function xsendfile_file(stored_file $file): bool {
|
||||
return $this->filesystem->xsendfile_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve file content using X-Sendfile header.
|
||||
* Please make sure that all headers are already sent
|
||||
|
||||
@@ -435,6 +435,21 @@ abstract class file_system {
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve file content using X-Sendfile header.
|
||||
* Please make sure that all headers are already sent and the all
|
||||
* access control checks passed.
|
||||
*
|
||||
* This alternate method to xsendfile() allows an alternate file system
|
||||
* to use the full file metadata and avoid extra lookups.
|
||||
*
|
||||
* @param stored_file $file The file to send
|
||||
* @return bool success
|
||||
*/
|
||||
public function xsendfile_file(stored_file $file): bool {
|
||||
return $this->xsendfile($file->get_contenthash());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve file content using X-Sendfile header.
|
||||
* Please make sure that all headers are already sent and the all
|
||||
|
||||
@@ -43,6 +43,7 @@ information provided here is intended especially for developers.
|
||||
* External functions can be called without requiring a session lock if they define 'readonlysession' => true in
|
||||
db/services.php. Note - this also requires $CFG->enable_read_only_sessions to be set to true.
|
||||
* database_manager::check_database_schema() now checks for missing and extra indexes.
|
||||
* Implement a more direct xsendfile_file() method for an alternative_file_system_class
|
||||
|
||||
=== 3.8 ===
|
||||
* Add CLI option to notify all cron tasks to stop: admin/cli/cron.php --stop
|
||||
|
||||
Reference in New Issue
Block a user