mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-19 14:36:48 +00:00
Throw exception on fopen failure in streaming encoding
This commit is contained in:
@@ -319,14 +319,19 @@ class Csv extends BaseReader
|
||||
private function convertEncodingStreaming(string $filename): void
|
||||
{
|
||||
$sourceHandle = fopen($filename, 'rb');
|
||||
// Using php://temp instead of php://memory: spills to disk when data
|
||||
// exceeds 2MB, reducing peak memory for large files.
|
||||
$outputHandle = fopen('php://temp', 'r+b');
|
||||
if ($sourceHandle === false || $outputHandle === false) {
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($sourceHandle !== false) {
|
||||
fclose($sourceHandle);
|
||||
}
|
||||
if ($outputHandle !== false) {
|
||||
fclose($outputHandle);
|
||||
}
|
||||
|
||||
return;
|
||||
throw new ReaderException("Failed to open file for encoding conversion: {$filename}");
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user