Skip to content

#208 - Fix FolderBrowserTask, InputFolderBrowserTask, CsvReaderTask and LineReaderTask (and their Input* variants) - #219

Merged
njoubert-cleverage merged 2 commits into
mainfrom
208
Sep 28, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
208

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #208.

FolderBrowserTask, CsvReaderTask and LineReaderTask (and their Input* variants) do not reset their internal iterator or file once an iteration is finished. If the task runs again, for example because it receives a second input from an upstream iterable task, it does not start over:

  • FolderBrowserTask / InputFolderBrowserTask, same folder twice: the second pass logs a false "No item found" and outputs nothing.
  • InputFolderBrowserTask, two different folders: throws LogicException: Folder path '…/dB' already initialized with a different value …/dA, the folder path being only cleared on flush().
  • CsvReaderTask / InputCsvReaderTask, same path twice: the second pass outputs nothing (skipped).
  • LineReaderTask / InputLineReaderTask, same path twice: the second pass outputs false.

JsonStreamReaderTask, CsvSplitterTask and AbstractIterableOutputTask already release their state at the end of the iteration.

This PR:

Release the state in next() once the iteration is over, as JsonStreamReaderTask::next() already does:

  • FolderBrowserTask: reset $files to null;
  • InputFolderBrowserTask: override next() to also reset $folderPath (a different path received mid-iteration still throws);
  • CsvReaderTask: close the CSV file and reset it to null;
  • LineReaderTask: reset the SplFileObject to null.

The Input* variants inherit the fix: each new input, same path or not, is read from its beginning. Update the reference documentation, add unit tests.

The new regression tests fail on main and pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None.

🤖 Generated with Claude Code

njoubert-cleverage and others added 2 commits September 28, 2026 12:04
…erTask and LineReaderTask (and their `Input*` variants): reset the state at the end of the iteration, so that a following input is read from its beginning. Update documentation, add tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit 6f61a97 into main Sep 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iterable file readers keep their state after a complete iteration: FolderBrowserTask, InputFolderBrowserTask, CsvReaderTask, LineReaderTask

1 participant