Fix empty STDIN handling in user import-csv#619
Conversation
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Fixes wp user import-csv - behavior when STDIN is present but no CSV content is actually provided, ensuring the command fails with the existing STDIN error instead of exiting successfully with no effect.
Changes:
- Add a post-parse validation in
User_Command::import_csv()to detect empty/invalid STDIN reads and emitUnable to read content from STDIN. - Re-enable the Behat scenario for importing users from STDIN by removing the
@brokentag.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/User_Command.php |
Adds an error-path after attempting to parse php://stdin for import-csv - to avoid silent no-op when STDIN has no usable CSV content. |
features/user-import-csv.feature |
Re-enables the STDIN import scenario test by removing the @broken marker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes
wp user import-csv -when no CSV content is provided on STDIN.The old broken test could not just be re-enabled, because the command could exit successfully when STDIN was detected but no CSV header or rows were read. This adds a small check after parsing STDIN so the command returns the existing error instead of silently doing nothing.
Testing
composer behat features/user-import-csv.feature:143composer behat features/user-import-csv.featurecomposer lintcomposer phpcscomposer phpstancomposer phpunitgit diff --check