Skip to content

exclude_block_comments_from_admin filter affects subsquent queries. #71711

@peterwilsoncc

Description

@peterwilsoncc

Description

The filter exclude_block_comments_from_admin on the pre_get_comments hook affects the queries for subsequent calls to get_comments() etc.

This occurs because a filter is added to comments_clauses to modify the clause without relation to the comments being queried.

Step-by-step reproduction 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 commands in wp-cli to view the error, the second call is expected to show the block comments
wp> get_comments( ['post_id' => 89, 'fields' => 'ids'] );
=> array(2) {
  [0] =>
  int(8)
  [1] =>
  int(7)
}
wp> get_comments( ['post_id' => 89, 'fields' => 'ids', 'type' => 'block_comment'] );
=> array(0) {
}

Screenshots, screen recording, code snippet

No response

Environment info

  • Gutenberg trunk @ c8b5138
  • WP 6.8.3-alpha-60773

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

Collaborative WorkflowsPhase 3 of the Gutenberg roadmap around all-things related to collaborative workflows[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

Projects

Status

Done

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions