Make WordPress Core

Opened 19 months ago

Last modified 16 months ago

#58156 new enhancement

finetune wp_update_comment_count

Reported by: presskopp's profile 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)

58156.diff (548 bytes) - added by Presskopp 19 months ago.

Download all attachments as: .zip

Change History (2)

@Presskopp
19 months ago

#1 @Presskopp
16 months ago

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

Note: See TracTickets for help on using tickets.