Skip to content

Commit ef7a303

Browse files
committed
Handles Azure blob storage failure for large files
- The change updates the Azure Blob storage file system to use standard readfile() simplifying the code and aligning to latest PHP capabilities - get_remote_path_from_storedfile() function calls is_file_readable_locally_by_storedfile() hence calling it again is not needed - This allows site admin to control whether it should check for local or external first - The readfile() function in PHP is memory-efficient for large files since 2016 and readfile_allow_large might not be needed
1 parent 30a0ac5 commit ef7a303

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

classes/azure_blob_storage_file_system.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,21 @@
3030
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3131
*/
3232
class azure_blob_storage_file_system extends file_system {
33+
34+
/**
35+
* Output the content of the specified stored file.
36+
*
37+
* Note, this is different to get_content() as it uses the built-in php
38+
* readfile function which is more efficient.
39+
*
40+
* @param stored_file $file The file to serve.
41+
* @return void
42+
*/
43+
public function readfile(\stored_file $file) {
44+
$path = $this->get_remote_path_from_storedfile($file);
45+
if (readfile($path) === false) {
46+
throw new \file_exception('storedfilecannotreadfile', $file->get_filename());
47+
}
48+
}
49+
3350
}

0 commit comments

Comments
 (0)