Repository navigation
#259 - JsonStreamWriterTask: add a mode option - #261
Merged
Merged
Conversation
…e.g. ab to append to an existing JSON Lines file), and release the file on finalize(). Update documentation, add tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
3 tasks
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 #259.
JsonStreamWriterTaskalready exists (since #168, withspl_file_object_flags/json_flagssince #172) and already matches most of the issue: blocking task, each array input written as one line withJsonStreamFile::writeLine(),proceed()outputs the file path,{date}/{date_time}/{timestamp}/{unique_token}placeholders, non-array input rejected with an\UnexpectedValueException. Documented indocs/reference/tasks/json_stream_writer_task.md.What was missing, added here:
modeoption (string, defaultwb, which was hard-coded): e.g.abto append to an existing JSON Lines file;finalize(), as the CSV tasks (CsvWriterTask: a non-array input throws a TypeError when headers is null, and the task cannot run again after finalize() #241).Tests added in
JsonStreamWriterTaskTest: overwrite by default,abmode appends,modetype validation, placeholders replaced in both the written and output path, non-array input,finalize(). PHPStan, PHPUnit (869 tests), PHP-CS-Fixer and Rector pass. Demonstrated bydemo.file.json_stream_writer_appendin process-bundle-demo.Requirements
Breaking changes
None: new option whose default is the previous behaviour.
🤖 Generated with Claude Code