-
Notifications
You must be signed in to change notification settings - Fork 95
feat: add --all flag to comment delete command #546
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
Open
shawnhooper
wants to merge
26
commits into
wp-cli:main
Choose a base branch
from
shawnhooper:delete_all_comments
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
0ccc287
feat: add --all flag to comment delete command
shawnhooper be45039
fix: linting errors
shawnhooper 24f1c4c
fix: phpstan issues
shawnhooper c4d8775
fix: phpstan issues
shawnhooper ea5d314
fix: incorrect return type
shawnhooper 846b801
fix: always return array
shawnhooper 6dbf62d
fix: code style
shawnhooper e0f124b
fix: update test expectations to handle comment deletion order
shawnhooper 000c832
fix: remove $exclude code
shawnhooper 860bb2b
fix: defer comment counts
shawnhooper 3af6933
fix: strict comparison on mixed
shawnhooper 3c9ea3c
fix: strict comparison on mixed
shawnhooper 95e7211
fix: phpcs comparison
shawnhooper 1e396e8
fix: behat tests. Add checks for multiple success lines
shawnhooper a7849ca
fix: behat tests. Add checks for multiple success lines
shawnhooper 669caae
test: Delete comments with explicit defer-term-counting flag
shawnhooper 8a3df5b
test: Success/Error returns
shawnhooper db90889
fix: remove --defer-comment-count flag, not referenced in coommand def
shawnhooper 1c8144c
test: return to STDERR
shawnhooper 37c0ba6
test: combined success/warning output to STDOUT
shawnhooper 61f74b6
test: trying to get combined success/fail ouput
shawnhooper d33e0b8
test: add blank line to return
shawnhooper fc0e2a2
test: could it be STDERR, now that we have the foramtting fixed?
shawnhooper fb2d6be
test: Separates STDOUT and STDERR
shawnhooper d0dd60a
Last try on STDOUT
shawnhooper a8bdff2
test: ah, the problem was I try vs I run
shawnhooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like it could be very slow on a large site
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I didn't like the looping either, but I wanted it to still trigger the
delete_commentanddeleted_commenthooks.Do you have any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which makes sense I suppose, there is usually a lot attached to these filters. And
wp_delete_commentitself does a lot as well, such as moving up children, deleting comment meta, and updating comment count. Plus, only this way can we adhere to the--forceflag as well.So yeah... there might be no way around it. Maybe it would be worth adding a warning to the docblock to indicate this might be slow if there are lots of comments.
We should probably use
wp_defer_comment_counting()to defer updating comment counts, otherwise it will be done after every single deletion.Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swissspidy Ok. I've added in the support for
wp_defer_comment_counting. This got a little more complex, since the call to theparent::_delete()function exited WP-CLI after a single delete.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shawnhooper That's amazing, thanks a lot for diving straight in!
I see you're battling with the Behat tests. Tip: If you are expecting an error output in a test, you need to use
When I try ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swissspidy Yep, that did it! Thanks, was really banging my head against my desk. Thinking it was STDOUT vs STDERR issues, etc.