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

Don't require the --force flag for deleting already trashed posts #292

Open
ocean90 opened this issue May 12, 2020 · 1 comment
Open

Don't require the --force flag for deleting already trashed posts #292

ocean90 opened this issue May 12, 2020 · 1 comment

Comments

@ocean90
Copy link
Contributor

ocean90 commented May 12, 2020

Bug Report

Describe the current, buggy behavior

The wp post delete command has this example

* # Delete all posts in the trash
* $ wp post delete $(wp post list --post_status=trash --format=ids)
* Success: Deleted post 1268.
* Success: Deleted post 1294.

Running this example for a custom post type doesn't work because the --force flag is missing, introduced in #188.

Describe how other contributors can replicate this bug

  • Create a CPT
  • Create a post for that CPT and trash it manually
  • Now try to delete the post

Describe what you would expect as the correct outcome

The post should be deleted without a warning because it's already in trash.

Provide a possible solution

Skip the check in

if ( ! $assoc_args['force']
&& ( 'post' !== $post_type && 'page' !== $post_type ) ) {
return [
'error',
"Posts of type '{$post_type}' do not support being sent to trash.\n"
. 'Please use the --force flag to skip trash and delete them permanently.',
];
}
if$status is trash.

@danielbachhuber
Copy link
Member

Thanks for the suggestion, @ocean90

I'm open to making this change, although it'd technically be a breaking change so we'd need to communicate such accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants