Make WordPress Core

Opened 6 weeks ago

Closed 13 days ago

#65613 closed defect (bug) (fixed)

Notes should not appear in comments feed

Reported by: odkdn1 Owned by: adamsilverstein
Priority: normal Milestone: 7.0.3
Component: Comments Version: 7.0.1
Severity: normal Keywords: commit fixed-major dev-reviewed
Cc: Focuses: privacy

Description

Related to https://core.trac.wordpress.org/ticket/64145 the RSS feeds at <site-url>/comments/feed and <site-url>/comments/feed/atom still show internal notes to the public.

Quote from the referenced issue:

Notes should never appear in the context of regular (front end) comments. Although they share the same comments table, notes use a specific "note" comment type. Notes of this type need to be consistently excluded wherever comments or comment counts are shown.

Change History (15)

#2 @adamsilverstein
5 weeks ago

Thanks for the bug report @odkdn1 - I'll take a look.

#4 @westonruter
5 weeks ago

  • Owner set to adamsilverstein
  • Status newassigned

@westonruter commented on PR #12486:


5 weeks ago
#5

I confirmed that the three new tests all fail when running against trunk as expected:

There were 3 failures:

1) Tests_Query_CommentFeed::test_main_comment_feed_should_exclude_notes
Comments feed should not include notes.
Failed asserting that an array does not contain 17.

/var/www/tests/phpunit/tests/query/commentFeed.php:113

2) Tests_Query_CommentFeed::test_archive_comment_feed_should_exclude_notes
Archive comments feed should not include notes.
Failed asserting that an array does not contain 18.

/var/www/tests/phpunit/tests/query/commentFeed.php:142

3) Tests_Query_CommentFeed::test_single_comment_feed_should_exclude_notes
Singular comments feed should not include notes.
Failed asserting that an array does not contain 19.

/var/www/tests/phpunit/tests/query/commentFeed.php:175

#6 @adamsilverstein
5 weeks ago

@odkdn1 can you give https://github.com/WordPress/wordpress-develop/pull/12486 a test to verify it fixes the issue you reported?

gubser commented on PR #12486:


5 weeks ago
#7

I tested it and it works, thank you :+1:

Steps

  1. Created dev environment from trunk.
  2. Added note, set to resolved.
  3. Note appears in http://localhost:8889/comments/feed and http://localhost:8889/comments/feed/atom
  4. Switched to [adamsilverstein:fix/65613-notes-comment-feed your branch]
  5. Rebuild
  6. Note does not appear anymore in http://localhost:8889/comments/feed and http://localhost:8889/comments/feed/atom

#8 @khokansardar
5 weeks ago

Patch testing report

Patch / PR tested

Environment

WordPress: 7.1-alpha-62161-src
PHP: 8.2.18 (Docker)
MySQL: 8.0.36
OS: macOS 26.5.2
Verified at the query layer via PHPUnit (Tests_Query_CommentFeed), all three raw feed paths
Local wordpress-develop @ http://localhost:8889

Steps

  1. Checked out PR branch fix/65613-notes-comment-feed, ran npm run build:dev.
  2. Ran the three new tests (test_main/archive/single_comment_feed_should_exclude_notes).
  3. Reverted ONLY src/wp-includes/class-wp-query.php back to trunk (keeping the new tests), rebuilt, and re-ran the three tests to reproduce the bug.
  4. Restored the fix, rebuilt, and re-ran the three tests plus the full commentFeed.php class and the feed/feeds groups.

Results

  • Before state (fix reverted): fail as expected — the note comment leaks into all three feeds (main #17, archive #18, singular #19), reproducing the ticket.
  • Main/front-page comment feed: pass — note excluded, all 15 regular comments retained.
  • Archive/search comment feed: pass — note excluded, count correct (15).
  • Singular post comment feed: pass — note excluded, count correct (5).
  • Regression: pass — full commentFeed.php (6 tests), feed group (44 tests, 318 assertions), feeds group all green.

Conclusion
PR #12486 adds comment_type != 'note' to the three raw comment-feed WHERE clauses in WP_Query, closing the gap left by [61105] / #64145, which only guarded WP_Comment_Query. The change is minimal (3 production lines), idiomatic, and matches the raw-SQL exclusion already used by wp_count_comments(). It is NULL-safe (comment_type is NOT NULL DEFAULT '', so regular/pingback/trackback comments are retained) and column-qualified so it is unambiguous under the posts JOIN. No backward-compatibility concern: the singular exclusion sits inside the default value passed to the comment_feed_where filter, so plugins can still adjust it. The only extra-scope items are test-only cosmetics (typed static properties, : void return types). Recommend commit.

#9 @adamsilverstein
5 weeks ago

  • Keywords commit added
  • Milestone Awaiting Review7.1

#10 @adamsilverstein
4 weeks ago

  • Resolutionfixed
  • Status assignedclosed

In 62804:

Comments: Exclude notes from comment feed queries.

Add comment_type != 'note' to the three raw comment feed queries, matching the exclusion already used by WP_Comment_Query and wp_count_comments(). [61105] excluded the note type in WP_Comment_Query, but the comment feed queries are built with raw SQL that bypasses WP_Comment_Query entirely, so the exclusion never reached feeds.

Follow-up to [61105].

Props westonruter, wildworks, mukesh27, odkdn1, khokansardar.
Fixes #65613.

#11 @ehtis
3 weeks ago

Hi @odkdn1

Is there a preferred way you would like to be credited in an upcoming WP release post? So far we have 'odkdn1' linking to your WordPress.org profile.

#12 @odkdn1
3 weeks ago

@ehtis Thank you for asking. You can use my full name Elio Gubser.

#13 @jorbin
2 weeks ago

  • Keywords fixed-major dev-feedback added
  • Milestone 7.17.0.3
  • Resolution fixed
  • Status closedreopened

Based on the reported version, I think this would be good to backport [62804] to the 7.0 branch. I am looking for a 2nd committer to sign off on this.

#14 @desrosj
2 weeks ago

  • Keywords dev-reviewed added; dev-feedback removed

[62804] looks good to backport.

#15 @jorbin
13 days ago

  • Resolutionfixed
  • Status reopenedclosed

In 63035:

Comments: Exclude notes from comment feed queries.

Add comment_type != 'note' to the three raw comment feed queries, matching the exclusion already used by WP_Comment_Query and wp_count_comments(). [61105] excluded the note type in WP_Comment_Query, but the comment feed queries are built with raw SQL that bypasses WP_Comment_Query entirely, so the exclusion never reached feeds.

Follow-up to [61105].

Reviewed by jorbin, desrosj.
Merges [62804] to 7.0 branch.

Props adamsilverstein, westonruter, wildworks, mukesh27, odkdn1, khokansardar.
Fixes #65613.

Note: See TracTickets for help on using tickets.