Skip to content

Fix empty STDIN handling in user import-csv#619

Open
ekamran wants to merge 2 commits into
wp-cli:mainfrom
ekamran:fix-user-import-csv-empty-stdin
Open

Fix empty STDIN handling in user import-csv#619
ekamran wants to merge 2 commits into
wp-cli:mainfrom
ekamran:fix-user-import-csv-empty-stdin

Conversation

@ekamran
Copy link
Copy Markdown

@ekamran ekamran commented Jun 3, 2026

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:143
  • composer behat features/user-import-csv.feature
  • composer lint
  • composer phpcs
  • composer phpstan
  • composer phpunit
  • git diff --check

@ekamran ekamran requested a review from a team as a code owner June 3, 2026 07:00
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

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:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

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:123

You can find a list of all available Behat steps in our handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy linked an issue Jun 3, 2026 that may be closed by this pull request
@swissspidy swissspidy requested a review from Copilot June 3, 2026 08:56
@swissspidy swissspidy added this to the 2.8.12 milestone Jun 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 emit Unable to read content from STDIN.
  • Re-enable the Behat scenario for importing users from STDIN by removing the @broken tag.

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.

Comment thread src/User_Command.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check for content on STDIN is broken in Behat

3 participants