#208 - Fix FolderBrowserTask, InputFolderBrowserTask, CsvReaderTask and LineReaderTask (and their Input* variants) - #219
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #208.
FolderBrowserTask,CsvReaderTaskandLineReaderTask(and theirInput*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: throwsLogicException: Folder path '…/dB' already initialized with a different value …/dA, the folder path being only cleared onflush().CsvReaderTask/InputCsvReaderTask, same path twice: the second pass outputs nothing (skipped).LineReaderTask/InputLineReaderTask, same path twice: the second pass outputsfalse.JsonStreamReaderTask,CsvSplitterTaskandAbstractIterableOutputTaskalready release their state at the end of the iteration.This PR:
Release the state in
next()once the iteration is over, asJsonStreamReaderTask::next()already does:FolderBrowserTask: reset$filestonull;InputFolderBrowserTask: overridenext()to also reset$folderPath(a different path received mid-iteration still throws);CsvReaderTask: close the CSV file and reset it tonull;LineReaderTask: reset theSplFileObjecttonull.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
mainand pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.Requirements
Breaking changes
None.
🤖 Generated with Claude Code