MDL-60001 core_files: Use local file for gzopen

The gzopen method does not appear to support
file streams.
This commit is contained in:
Mark Nielsen
2017-08-31 15:47:00 -07:00
parent 9eb3c173ae
commit 879827d6fa
2 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -478,7 +478,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);
}
+2 -2
View File
@@ -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.