WordPress.org

Make WordPress Core

Ticket #34977: 34977.patch

File 34977.patch, 919 bytes (added by ambrosey, 4 years ago)
  • src/wp-includes/comment.php

     
    18761876        do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status );
    18771877
    18781878        wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
    1879 
    1880         wp_update_comment_count($comment->comment_post_ID);
    1881 
     1879       
     1880        if ( $comment->comment_post_ID ) {
     1881                wp_update_comment_count($comment->comment_post_ID);
     1882        }
    18821883        return true;
    18831884}
    18841885
     
    19471948        $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
    19481949
    19491950        clean_comment_cache( $comment_ID );
    1950         wp_update_comment_count( $comment_post_ID );
     1951        if ( $comment_post_ID ){
     1952                wp_update_comment_count( $comment_post_ID );
     1953        }
    19511954        /**
    19521955         * Fires immediately after a comment is updated in the database.
    19531956         *