Comments: Exclude notes from get_lastcommentmodified().#12573
Conversation
get_lastcommentmodified() returns the date of the most recent approved comment, and WP::send_headers() uses it to build the Last-Modified and ETag headers for the comments feed. The query did not exclude the internal 'note' comment type, so adding or resolving a note (approved, but never part of the public feed) changed the feed's Last-Modified/ETag even though the feed content -- which already excludes notes, see #64145 -- did not change. This defeated conditional GET (304) caching of the comments feed whenever notes are used, and exposed the timing of internal notes through a public response header. Add `comment_type != 'note'` to the three lastcommentmodified queries so notes no longer affect the value, matching the exclusion already used by wp_update_comment_count_now() and the comment feed queries. Adds a regression test. Fixes #65657.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket: https://core.trac.wordpress.org/ticket/65657
Summary
get_lastcommentmodified()returns the date of the most recent approved comment, andWP::send_headers()uses it (max'd withget_lastpostmodified()) to build theLast-ModifiedandETagheaders for the comments feed.Its three queries did not exclude the internal
notecomment type:Notes are stored as approved comments (
comment_type = 'note'), so adding or resolving a note makes it the most recent comment. The public comments feed'sLast-Modified/ETagthen change, even though the feed body already excludes notes (#64145 / #65613) and did not change.Consequences:
Last-Modifiedheader exposes the timing of internal editorial notes.Reproduction
On a site using Notes:
Verified live: adding one note moved
Last-ModifiedfromFri, 01 Jan 2027 10:00:00 GMTtoSat, 02 Jan 2027 10:00:00 GMTand changed theETag. See the before/after screenshots on the Trac ticket.Fix
Add
AND comment_type != 'note'to the threeget_lastcommentmodified()queries, matching the exclusion already used bywp_update_comment_count_now()and the comment feed queries.Testing
Added
test_notes_are_excludedtoTests_Comment_GetLastCommentModified.Failed asserting that <note timestamp> is identical to <regular-comment timestamp>.Full comment group is green:
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: Auditing the notes-exclusion surfaces, reproducing the feed-header change, implementing the fix, and writing the regression test. All changes were reviewed by me.