Skip to content

Commit 45b0349

Browse files
committed
Patch moved to the AbstractCsv::chunk method
1 parent 9fa6a86 commit 45b0349

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/AbstractCsv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public function chunk(int $length): Generator
262262

263263
$input_bom = $this->getInputBOM();
264264
$this->document->rewind();
265+
$this->document->setFlags(0);
265266
$this->document->fseek(strlen($input_bom));
266267
foreach (str_split($this->output_bom.$this->document->fread($length), $length) as $chunk) {
267268
yield $chunk;
@@ -311,7 +312,6 @@ public function output(string $filename = null): int
311312
}
312313
$input_bom = $this->getInputBOM();
313314
$this->document->rewind();
314-
$this->document->setFlags(0);
315315
$this->document->fseek(strlen($input_bom));
316316
echo $this->output_bom;
317317

tests/CsvTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,18 @@ public function testOutputHeaders()
172172
self::assertContains('Content-Disposition: attachment; filename="tst.csv"; filename*=utf-8\'\'t%C3%A9st.csv', $headers[3]);
173173
}
174174

175+
/**
176+
* @covers ::chunk
177+
* @covers ::getContent
178+
*/
179+
public function testChunkDoesNotTimeoutAfterReading()
180+
{
181+
$raw_csv = "john,doe,john.doe@example.com\njane,doe,jane.doe@example.com\n";
182+
$csv = Reader::createFromString($raw_csv);
183+
iterator_to_array($csv->getRecords());
184+
self::assertSame($raw_csv, $csv->getContent());
185+
}
186+
175187
/**
176188
* @covers ::__toString
177189
* @covers ::getContent

0 commit comments

Comments
 (0)