Skip to content

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

@karthick-murugan karthick-murugan requested a review from a team as a code owner March 18, 2025 15:05
@codecov
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 : )

@mrsdizzie mrsdizzie added bug command:user-update Related to 'user update' command labels Mar 18, 2025
@mrsdizzie mrsdizzie added this to the 2.8.3 milestone Mar 18, 2025
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

Labels

bug command:user-update Related to 'user update' command

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