Skip to content

Fix likes and reposts showing in standard Comments block when other plugins also filter comment types - #2981

Open
pfefferle wants to merge 7 commits into
trunkfrom
fix/comment-query-type-not-in-merge
Open

Fix likes and reposts showing in standard Comments block when other plugins also filter comment types#2981
pfefferle wants to merge 7 commits into
trunkfrom
fix/comment-query-type-not-in-merge

Conversation

@pfefferle

Copy link
Copy Markdown
Member

Fixes #2747

Proposed changes:

When another plugin (e.g. Friends, Webmention, Event Bridge) registers a pre_get_comments callback that sets type__not_in, ActivityPub was silently skipping its own exclusion of likes, reposts, and quote comment types. This caused those interactions to appear in the standard WordPress Comments block even when the Fediverse Reactions block was also present on the page.

The fix merges ActivityPub's comment type exclusions with any existing type__not_in values instead of bailing out early when type__not_in is already set.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  1. Install a plugin that adds custom comment types to type__not_in via pre_get_comments (e.g. Webmention, Friends).
  2. Receive a Like or Repost on a post from the Fediverse.
  3. View that post on the front end with both the standard Comments block and the Fediverse Reactions block present.
  4. Before fix: Likes/Reposts appear in the standard Comments block.
  5. After fix: Likes/Reposts are correctly excluded from the standard Comments block and only appear in the Fediverse Reactions block.

Changelog entry

Significance: Patch, Type: Fixed

Fix likes and reposts appearing in the standard Comments block when another plugin also filters comment types.

… plugin also excludes comment types.

When a plugin like Friends or Webmention set type__not_in on the comment query via
pre_get_comments, ActivityPub silently skipped adding its own exclusions. Merge
the ActivityPub comment types with any existing type__not_in values instead of bailing out.

Fixes #2747
@pfefferle
pfefferle marked this pull request as ready for review August 28, 2026 07:55
Copilot AI lite review requested due to automatic review settings August 28, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes front-end comment queries so ActivityPub reaction comment types (e.g., likes/reposts) remain excluded from the standard WordPress Comments block even when another plugin pre-populates type__not_in via pre_get_comments (issue #2747).

Changes:

  • Update Activitypub\Comment::comment_query() to merge ActivityPub’s excluded comment types into any existing type__not_in values instead of returning early.
  • Add a PHPUnit test that simulates another plugin setting type__not_in before ActivityPub’s callback runs.
  • Add a Patch/Fixed changelog fragment describing the user-visible fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
includes/class-comment.php Merges ActivityPub reaction comment-type exclusions with existing type__not_in values in comment_query().
tests/phpunit/tests/includes/class-test-comment.php Adds regression test coverage for the type__not_in merge scenario.
.github/changelog/fix-comment-query-type-not-in-merge Patch changelog entry documenting the fix for end users.
Suppressed comments (1)

tests/phpunit/tests/includes/class-test-comment.php:1817

  • After adding Repost/Quote fixtures for this scenario, the assertions here should also verify those types are excluded alongside Like, so the test matches the behavior of get_comment_type_slugs().
		$this->assertContains( (string) $regular_comment_id, $comment_ids, 'Regular comment should be included.' );
		$this->assertNotContains( (string) $like_comment_id, $comment_ids, 'Like should be excluded even when another plugin sets type__not_in first.' );
		$this->assertNotContains( (string) $webmention_comment_id, $comment_ids, 'Webmention (excluded by the other plugin) should also be excluded.' );

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread includes/class-comment.php Outdated
Comment thread tests/phpunit/tests/includes/class-test-comment.php

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug/UX] Standard Comments Block displays Likes/Reposts even when "Fediverse Reactions" block is present

2 participants