Skip to content

Conversation

peterwilsoncc
Copy link
Contributor

What?

Fixes the comment filtering clause for block comments to avoid affecting subsequent queries.

Closes #71711

Why?

Affecting subsequent queries is bad.

How?

Moves the filtering to take place on comments_clauses exclusively by checking the query parameters on the clause filter.

The filter for pre_get_comments is removed.

Testing Instructions

  1. Create and publish a post
  2. Write two block comments on the post via editor
  3. Write two actual comments on the post via the front end
  4. Approve the front end comments if required by your moderation settings
  5. Run the following in wp shell, replacing the post ID with the ID created above
wp> get_comments( ['post_id' => 89, 'fields' => 'ids'] );
// Ensure the resulting IDs do not include the block comments
wp> get_comments( ['post_id' => 89, 'fields' => 'ids', 'type' => 'block_comment'] );
// Ensure the resulting IDs include the block comments and not the front end comments

Testing Instructions for Keyboard

N/A

Screenshots or screencast

N/A

Copy link

github-actions bot commented Sep 17, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: peterwilsoncc <[email protected]>
Co-authored-by: adamsilverstein <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@peterwilsoncc peterwilsoncc self-assigned this Sep 17, 2025
@peterwilsoncc peterwilsoncc added [Type] Bug An existing feature does not function as intended Collaborative Workflows Phase 3 of the Gutenberg roadmap around all-things related to collaborative workflows labels Sep 17, 2025
Copy link
Member

@adamsilverstein adamsilverstein 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!

@adamsilverstein
Copy link
Member

Code looks good, checking to verify this fixes the issue...

@adamsilverstein
Copy link
Member

This works well in my testing, thanks @peterwilsoncc!

@adamsilverstein adamsilverstein merged commit c771f4f into trunk Sep 17, 2025
75 of 77 checks passed
@adamsilverstein adamsilverstein deleted the fix/71711-comment-filter branch September 17, 2025 22:19
@github-actions github-actions bot added this to the Gutenberg 21.8 milestone Sep 17, 2025
peterwilsoncc added a commit that referenced this pull request Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Collaborative Workflows Phase 3 of the Gutenberg roadmap around all-things related to collaborative workflows [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exclude_block_comments_from_admin filter affects subsquent queries.
2 participants