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

Warn on delete failure, instead of hard exiting #376

Merged
merged 3 commits into from
Oct 11, 2023
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
29 changes: 29 additions & 0 deletions features/plugin-delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,32 @@ Feature: Delete WordPress plugins
Success:
"""
And the return code should be 0

Scenario: Reports a failure for a plugin that can't be deleted
Given a WP install

When I run `chmod -w wp-content/plugins/akismet`
And I try `wp plugin delete akismet`
Then STDERR should contain:
"""
Warning: The 'akismet' plugin could not be deleted.
"""
And STDERR should contain:
"""
Error: No plugins deleted.
"""
Then STDOUT should not contain:
"""
Success:
"""

When I run `chmod +w wp-content/plugins/akismet`
And I run `wp plugin delete akismet`
Then STDERR should not contain:
"""
Error:
"""
Then STDOUT should contain:
"""
Success:
"""
3 changes: 2 additions & 1 deletion src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ public function delete( $args, $assoc_args = array() ) {
WP_CLI::log( "Deleted '{$plugin->name}' plugin." );
++$successes;
} else {
WP_CLI::warning( "The '{$plugin->name}' plugin could not be deleted." );
++$errors;
}
}
Expand Down Expand Up @@ -1297,6 +1298,6 @@ private function delete_plugin( $plugin ) {
$command = 'rm -rf ';
}

return ! WP_CLI::launch( $command . escapeshellarg( $path ) );
return ! WP_CLI::launch( $command . escapeshellarg( $path ), false );
}
}