[wp-trac] [WordPress Trac] #8071: Refrain from querying all the comments on a post when paged

WordPress Trac noreply at wordpress.org
Fri Sep 25 19:34:29 UTC 2015


#8071: Refrain from querying all the comments on a post when paged
------------------------------------+---------------------------
 Reporter:  markjaquith             |       Owner:  boonebgorges
     Type:  enhancement             |      Status:  assigned
 Priority:  normal                  |   Milestone:  4.4
Component:  Comments                |     Version:  2.7
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+---------------------------

Comment (by boonebgorges):

 [attachment:8071.7.diff] is what remains to fix this issue.

 The way that comment pagination works is complicated and not very
 intuitive. The 0th page of comments - what you see when reading a post
 with no 'cpage' query var - contains either the most recent or the oldest
 #per_page comments, depending on your 'default_comments_page' setting.
 However, the behavior of non-zero 'cpage' is *not* sensitive to
 'default_comments_page'; cpage=2 always contains more recent comments than
 cpage=3, etc. In other words, when 'default_comments_page=newest', the
 order of comment pages (if you have 4 pages total) is 0, 3, 2, 1, where if
 you show the oldest page first, the order is 0, 1, 2, 3. (The magic, such
 as it is, is in `Walker_Comment`.)

 I don't think this makes a lot of sense, but I also don't know what would
 break if we changed the behavior. It's very likely that someone out there
 is building custom pagination links, and is expecting the behavior
 described above.

 In order to introduce pagination that respects the new pagination powers
 of `WP_Comment_Query` - which are the key to making comment pagination
 scale - without breaking backward compatibility for comment pagination
 URLs, I've put a couple of pretty awful hacks into `comment_template()`.
 The hacks would be slightly less ugly if I put them into the Walker or
 into `wp_list_comments()`, but both of these could have unexpected
 consequences, because of the various ways they're used. By isolating
 everything inside of the already hideous `comments_template()`, I've
 greatly limited the possibility of collateral damage.

 Primary problem at this point: I discovered that wonderboymusic's
 technique for forcing 'page_comments' is incomplete. When pretty
 permalinks are enabled, `redirect_canonical()` will check to see if
 `get_option( 'page_comments' )` is enabled. If not, it disregards
 'comment-page-x' URL chunks, so that comment pagination links get
 redirected back to the post itself. No query has taken place at this
 point, so there's no way we can force the threshold for pagination based
 on comment count. In [attachment:8071.7.diff], I removed the `get_option(
 'page_comments' )` check from `redirect_canonical()`. But, as I mentioned
 above, this effectively neuters the 'page_comments' settings. It may be
 time to kill the setting.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/8071#comment:33>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list