[wp-trac] [WordPress Trac] #8973: Function get_page_of_comment() returns incorrect page numbers
WordPress Trac
noreply at wordpress.org
Sun Sep 15 21:39:50 UTC 2019
#8973: Function get_page_of_comment() returns incorrect page numbers
---------------------------+-----------------------
Reporter: GregMulhauser | Owner: pento
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 5.3
Component: Comments | Version: 2.7
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
---------------------------+-----------------------
Changes (by imath):
* keywords: has-patch needs-refresh => has-patch
Comment:
Hi,
I've managed to reproduce an issue a bit different than the one described
in this [https://core.trac.wordpress.org/ticket/8973#comment:16 comment].
If I do the 3 steps listed to reproduce, the issue I get at last step is
I'm redirected to a wrong comments page and it's actually an "earlier"
one.
For example: if the redirected page should be `comment-page-3`, I'm
redirected to `comment-page-2`. I guess it's probably linked to whether
you want newest or oldest comments first.
To fix the issue, I find it a bit too bad to add new parameters to the
array argument of `get_comment_link()` and `get_page_of_comment()`.
Instead, in
[https://core.trac.wordpress.org/attachment/ticket/8973/8973.4.patch
8973.4.patch], I'm suggesting to create a new function to get the
`include_unapproved` arguments for the `comments_template()` and
`get_page_of_comment()` functions.
I also think it's important to add a new filter inside
`get_page_of_comment()` to make it possible just like it is in
`comments_template()` to edit the comments query arguments before actually
querying.
I agree with @pento It's important to keep the code relative to
`wp_get_current_commenter()` in `comments_template()`, because the issue
is also concerning these users.
I added two unit tests, one for Logged in user and another one for the
current commenter.
I've run `composer run format` on edited files.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/8973#comment:36>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list