Opened 19 months ago
Last modified 16 months ago
#58156 new enhancement
finetune wp_update_comment_count
Reported by: | Presskopp | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | has-patch |
Focuses: | Cc: |
Description
there is a @todo in function wp_update_comment_count
and I see no reason for not changing the code, which would make it a bit more effective.
current:
if ( $do_deferred ) {
$_deferred = array_unique( $_deferred );
foreach ( $_deferred as $i => $_post_id ) {
wp_update_comment_count_now( $_post_id );
unset( $_deferred[ $i ] );
/** @todo Move this outside of the foreach and reset $_deferred to an array instead */
}
}
new:
if ( $do_deferred ) {
$_deferred = array_unique( $_deferred );
foreach ( $_deferred as $i => $_post_id ) {
wp_update_comment_count_now( $_post_id );
}
$_deferred = array(); // for clarity, it is not even needed
}
Attachments (1)
Note: See
TracTickets for help on using
tickets.
I have to correct myself. The comment I made (which is not part of the patch, the patch is ok)
// for clarity, it is not even needed
is incorrect. In fact, the line is needed because of the following code.
The alternative is to just strip the @todo comment, because the performance gain here is minimal