diff --git a/lib/filestorage/file_system.php b/lib/filestorage/file_system.php index 21ebe77086e..ba6b8be8f6b 100644 --- a/lib/filestorage/file_system.php +++ b/lib/filestorage/file_system.php @@ -532,7 +532,12 @@ abstract class file_system { * @return resource file handle */ public function get_content_file_handle(stored_file $file, $type = stored_file::FILE_HANDLE_FOPEN) { - $path = $this->get_remote_path_from_storedfile($file); + if ($type === stored_file::FILE_HANDLE_GZOPEN) { + // Local file required for gzopen. + $path = $this->get_local_path_from_storedfile($file, true); + } else { + $path = $this->get_remote_path_from_storedfile($file); + } return self::get_file_handle_for_path($path, $type); } diff --git a/lib/filestorage/tests/file_system_test.php b/lib/filestorage/tests/file_system_test.php index 038cad1a317..159f06c78a8 100644 --- a/lib/filestorage/tests/file_system_test.php +++ b/lib/filestorage/tests/file_system_test.php @@ -904,8 +904,8 @@ class core_files_file_system_testcase extends advanced_testcase { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); - $fs = $this->get_testable_mock(['get_remote_path_from_storedfile']); - $fs->method('get_remote_path_from_storedfile') + $fs = $this->get_testable_mock(['get_local_path_from_storedfile']); + $fs->method('get_local_path_from_storedfile') ->willReturn(__DIR__ . "/fixtures/test.tgz"); // Note: We are unable to determine the mode in which the $fh was opened.