Open comment links on the page the comment is actually on - #3678
Open
pfefferle wants to merge 4 commits into
Open
Open comment links on the page the comment is actually on#3678pfefferle wants to merge 4 commits into
pfefferle wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect #comment-… permalinks on posts with many ActivityPub reactions by ensuring get_page_of_comment() uses the same comment-type exclusions as the rendered comment list (so it doesn’t compute a later cpage than where the comment actually appears).
Changes:
- Hook
get_page_of_comment_query_argsto exclude ActivityPub reaction comment types from the “older comments” count (except on ActivityPub requests or when a specific type is requested). - Add a PHPUnit regression test covering the incorrect
cpagebehavior. - Add a patch-level changelog entry describing the user-visible fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| includes/class-comment.php | Adds get_page_of_comment_query_args() filter to keep comment pagination math aligned with rendered exclusions. |
| tests/phpunit/tests/includes/class-test-comment.php | Adds a regression test ensuring get_page_of_comment()/get_comment_link() don’t point at the wrong cpage when older reactions exist. |
| .github/changelog/fix-comment-permalink-page | Documents the permalink pagination fix for release notes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes:
get_page_of_comment()counts the comments older than the given one withtype => 'all', the one value that makesWP_Comment_Queryskip every exclusion.comments_template()renders the same post with our comment types hidden. So on a post with a few likes or reposts older than a comment, core places that comment on a later page than the one it actually renders on, andget_comment_link()emits acpagethe comment is not on. Every#comment-permalink, reply notification link and feed link is affected once a post collects enough reactions.Reproduced with three reactions older than one comment, two per page:
This hooks
get_page_of_comment_query_argsso the count uses the same exclusion the list does. It steps aside on ActivityPub requests, where the list shows everything, and when a caller asks for a specific type.Core has had the same bug with its own
notetype since 6.9, and fixes it the same way in WordPress/wordpress-develop#12310, which is still open, so it does not help us yet.Split out of #2981 on request, it is a different bug in the same file.
Other information:
Testing instructions:
cpage=2, but the comment renders on page 1.cpage, the link opens on the page the comment is on.test_get_page_of_comment_ignores_hidden_reactionscovers it and fails with the hook removed.Changelog entry
In the branch as
.github/changelog/fix-comment-permalink-page, patch / fixed.