Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure wp user update Returns Non-Zero Exit Code for Invalid Users #527

Merged
merged 4 commits into from
Mar 19, 2025

Conversation

karthick-murugan
Copy link
Contributor

Fixes wp-cli/wp-cli#5960

This PR fixes the issue where wp user update incorrectly exits with 0 when the provided user ID is invalid. Now, when an invalid user ID, email, or login is supplied, the command will return an exit code of 1 instead of 0, ensuring proper error handling.

Testing Instructions

Try updating a non-existent user:
wp user update 9999 --user_pass=securepassword

Expected output:
Warning: Invalid user ID, email or login: '9999'

Expected exit code: 1
echo $?
Should return 1

Try updating a existent user:
wp user update 1 --user_pass=securepassword

Expected output:
Success: Updated user 1.

Expected exit code: 0
echo $?
Should return 0

Screenshot

user_update_command

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
@karthick-murugan karthick-murugan requested a review from a team as a code owner March 18, 2025 15:05
Copy link

codecov bot commented Mar 18, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Member

@mrsdizzie mrsdizzie left a comment

Choose a reason for hiding this comment

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

Also we should add a test for this : )

Copy link
Member

@mrsdizzie mrsdizzie left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@mrsdizzie mrsdizzie merged commit 7e7fd93 into wp-cli:main Mar 19, 2025
40 checks passed
@karthick-murugan karthick-murugan deleted the wpcli/user-update-command branch March 19, 2025 14:44
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.

wp user update for non-existent user should return non-zero RC
2 participants