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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ Feature: Manage WordPress users
3
"""

When I try `wp user update 9999 --user_pass=securepassword`
Then the return code should be 1
And STDERR should contain:
"""
Error: No valid users found.
"""

Scenario: Delete user with invalid reassign
Given a WP install
And a session_no file:
Expand Down
4 changes: 4 additions & 0 deletions src/User_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ public function update( $args, $assoc_args ) {
$user_ids[] = $user->ID;
}

if ( empty( $user_ids ) ) {
WP_CLI::error( 'No valid users found.' );
}

$skip_email = Utils\get_flag_value( $assoc_args, 'skip-email' );
if ( $skip_email ) {
add_filter( 'send_email_change_email', '__return_false' );
Expand Down