From dbecc4ee84018d28c920bccb3cad5ed790207834 Mon Sep 17 00:00:00 2001 From: ralf Date: Wed, 21 Feb 2024 19:44:55 +0200 Subject: [PATCH] * ImportExport: fix not working import from http(s) caused by trying to seek a non-seekable http steam --- .../inc/class.importexport_schedule_ui.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/importexport/inc/class.importexport_schedule_ui.inc.php b/importexport/inc/class.importexport_schedule_ui.inc.php index 8151079577..40e079ea4f 100644 --- a/importexport/inc/class.importexport_schedule_ui.inc.php +++ b/importexport/inc/class.importexport_schedule_ui.inc.php @@ -528,6 +528,15 @@ class importexport_schedule_ui { if (($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' ))) { + // if steam is NOT seekable (e.g. http), copy it into temp stream, which is + if ($data['type'] == 'import' && ($metadata=stream_get_meta_data($resource)) && + !$metadata['seekable'] && ($tmp = fopen('php://temp', 'r+'))) + { + stream_copy_to_stream($resource, $tmp); + fclose($resource); + fseek($tmp, 0); + $resource = $tmp; + } $result = $po->$type( $resource, $definition ); fclose($resource); @@ -685,4 +694,4 @@ class importexport_schedule_ui } return $result; } -} +} \ No newline at end of file