This filter allows developers to modify the output of `get_page_of_comment()`.
As a side effect of this new filter, comment page numbers will always be
returned as integers. Previously, they would sometimes be returned as floats -
eg `float(2.0)` instead of `int(2)`.
Props laceous.
See #13939.
Built from https://develop.svn.wordpress.org/trunk@34808
git-svn-id: http://core.svn.wordpress.org/trunk@34773 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The function now uses the following order of precedence when calculating
comment pagination: 1. the 'per_page' value passed in the `$args` array,
2. the 'comments_per_page' query var in `$wp_query`, and 3. the
'comments_per_page' setting from options-discussion.php. This change allows
`get_page_of_comment()` to return an accurate value before the main query
has been run.
Props laceous.
See #13939.
Built from https://develop.svn.wordpress.org/trunk@34806
git-svn-id: http://core.svn.wordpress.org/trunk@34771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible
for comment feeds to take advantage of metadata lazyloading, in addition to
comments loaded via `comments_template()`.
This new technique parallels the termmeta lazyloading technique introduced in
[34704].
Fixes#34047.
Built from https://develop.svn.wordpress.org/trunk@34711
git-svn-id: http://core.svn.wordpress.org/trunk@34675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, the 'page_comments' toggle allowed users to disable comment
pagination. This toggle was only superficial, however. Even with
'page_comments' turned on, `comments_template()` loaded all of a post's
comments into memory, and passed them to `wp_list_comments()` and
`Walker_Comment`, the latter of which produced markup for only the
current page of comments. In other words, it was possible to enable
'page_comments', thereby showing only a subset of a post's comments on a given
page, but all comments continued to be loaded in the background. This technique
scaled poorly. Posts with hundreds or thousands of comments would load slowly,
or not at all, even when the 'comments_per_page' setting was set to a
reasonable number.
Recent changesets have addressed this problem through more efficient tree-
walking, better descendant caching, and more selective queries for top-level
post comments. The current changeset completes the project by addressing the
root issue: that loading a post causes all of its comments to be loaded too.
Here's the breakdown:
* Comment pagination is now forced. Setting 'page_comments' to false leads to evil things when you have many comments. If you want to avoid pagination, set 'comments_per_page' to something high.
* The 'page_comments' setting has been expunged from options-discussion.php, and from places in the codebase where it was referenced. For plugins relying on 'page_comments', we now force the value to `true` with a `pre_option` filter.
* `comments_template()` now queries for an appropriately small number of comments. Usually, this means the `comments_per_page` value.
* To preserve the current (odd) behavior for comment pagination links, some unholy hacks have been inserted into `comments_template()`. The ugliness is insulated in this function for backward compatibility and to minimize collateral damage. A side-effect is that, for certain settings of 'default_comments_page', up to 2x the value of `comments_per_page` might be fetched at a time.
* In support of these changes, a `$format` parameter has been added to `WP_Comment::get_children()`. This param allows you to request a flattened array of comment children, suitable for feeding into `Walker_Comment`.
* `WP_Query` loops are now informed about total available comment counts and comment pages by the `WP_Comment_Query` (`found_comments`, `max_num_pages`), instead of by `Walker_Comment`.
Aside from radical performance improvements in the case of a post with many
comments, this changeset fixes a bug that caused the first page of comments to
be partial (`found_comments` % `comments_per_page`), rather than the last, as
you'd expect.
Props boonebgorges, wonderboymusic.
Fixes#8071.
Built from https://develop.svn.wordpress.org/trunk@34561
git-svn-id: http://core.svn.wordpress.org/trunk@34525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
[34537] hooked `wp_new_comment_notify_postauthor()` to the
'wp_set_comment_status' when a comment had been approved. When performing
multiple actions on a comment in the same request (as happens in
`Tests_Ajax_DeleteComment::test_ajax_trash_double_action()`, and may happen
sometimes in real life too), and when one of those actions involves deleting
the comment, the `$comment_ID` passed to `wp_new_comment_notify_postauthor()`
can correspond to an already-deleted comment. The `comment_status` check should
account for this possibility.
See #14078.
Built from https://develop.svn.wordpress.org/trunk@34545
git-svn-id: http://core.svn.wordpress.org/trunk@34509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This is part of the project of #33587.
Moving this particular message to the
'wp_set_comment_status' action has the added bonus that the notification is
sent after the comment status has been updated in the database. Previously, a
database error could lead to a case where an approval notification is sent,
but the comment status change fails for some reason.
Props mrmist, NickDuncan.
Fixes#14078.
Built from https://develop.svn.wordpress.org/trunk@34537
git-svn-id: http://core.svn.wordpress.org/trunk@34501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`wp_allow_comment()` disallows a comment if it matches a comment on the same
post with the same content, author email, and parent. This new filter allows
developers to circumvent or modify this logic, making the duplicate check
more or less lenient, as they see fit.
Fixes#9775.
Built from https://develop.svn.wordpress.org/trunk@34536
git-svn-id: http://core.svn.wordpress.org/trunk@34500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The new `$comment_meta` parameter of `wp_insert_comment()` allows an array of
key/value pairs to be passed when creating a comment. These pairs are then
stored as commentmeta when the comment has been created.
Props tellyworth, wonderboymusic.
Fixes#12431.
Built from https://develop.svn.wordpress.org/trunk@34533
git-svn-id: http://core.svn.wordpress.org/trunk@34497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`WP_Comment_Query` now fetches comments in two stages: (1) a query to get the
IDs of comments matching the query vars, and (2) a query to populate the
objects corresponding to the matched IDs. The two queries are cached
separately, so that sites with persistent object caches will continue to have
complete cache coverage for normal comment queries.
Splitting the query allows our cache strategy to be more modest and precise, as
full comment data is only stored once per comment. It also makes it possible
to introduce logic for paginated threading, which is necessary to address
certain performance problems.
See #8071.
data is only stored once per comment, instead of along with
Built from https://develop.svn.wordpress.org/trunk@34310
git-svn-id: http://core.svn.wordpress.org/trunk@34274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
[34268] introduced cache priming for commentmeta, enabled by default. To
ensure performance on single post pages - where commentmeta is most likely
to cause performance issues - we disable up-front cache-priming. Instead, we
prime commentmeta caches for all comments in the loop the first time
`get_comment_meta()` is called on the page.
Props bradt, dd32, wonderboymusic, boonebgorges.
Fixes#16894.
Built from https://develop.svn.wordpress.org/trunk@34270
git-svn-id: http://core.svn.wordpress.org/trunk@34234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The new 'update_comment_meta_cache' parameter, which defaults to `true`, can
be used to disable this behavior.
`update_comment_cache()` has been updated to support an `$update_meta_cache`
parameter, which also updates to true; this matches the pattern we use for
priming post caches.
See #16894.
Built from https://develop.svn.wordpress.org/trunk@34268
git-svn-id: http://core.svn.wordpress.org/trunk@34232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
[34106] moved post author notification to a hook, and in the process, missed
the 'spam' check. This changeset restores that check.
To make unit testing easier, the notification callbacks have been refactored
to return values: false when various conditions aren't met (eg, approved
comments should not trigger moderation emails), and the return value of the
`wp_notify_*()` function otherwise.
Props cfinke, kraftbj.
See #33587.
Built from https://develop.svn.wordpress.org/trunk@34250
git-svn-id: http://core.svn.wordpress.org/trunk@34214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Takes inspiration from `WP_Post` and adds sanity to comment caching.
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now
Props wonderboymusic, nacin.
See #32619.
Built from https://develop.svn.wordpress.org/trunk@33891
git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd