[wp-trac] Re: [WordPress Trac] #7956: get_comment_link() should be
paged comments aware
WordPress Trac
wp-trac at lists.automattic.com
Tue Nov 4 11:25:52 GMT 2008
#7956: get_comment_link() should be paged comments aware
--------------------------+-------------------------------------------------
Reporter: Viper007Bond | Owner:
Type: defect | Status: reopened
Priority: high | Milestone: 2.7
Component: Comments | Version: 2.7
Severity: normal | Resolution:
Keywords: |
--------------------------+-------------------------------------------------
Changes (by Viper007Bond):
* status: closed => reopened
* resolution: fixed =>
Comment:
`get_comment_link()` is currently using using a heavy MySQL query every
single time it's called (due to a call to `get_comments()` inside of
`get_page_of_comment()`).
Incoming patch (which were all Mark's ideas) ditches the usage of
`get_comments()` inside of `get_page_of_comment()` and instead just does a
simple, lightweight query to find the number of older top-level comments.
That's all that's needed as you can then divide that count by the comments
per page to get what page that comment is on.
However this patch also allows you to skip even that query by passing a
`$page` value to `get_comment_link()` if it's known (i.e. if you're in the
regular comment loop and not in the sidebar). That way we can recycle the
value and don't have to calculate the page for every single
`get_comment_link()` call.
Oh, and the patch also updates the Recent Comments widget to use
`get_comment_link()` (I used it for testing) and fixes a "bug" that
resulted in `get_comments()` returning only the 4 columns that the widget
queried for (due to caching).
--
Ticket URL: <http://trac.wordpress.org/ticket/7956#comment:17>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list