Make WordPress Core

Ticket #22917: 22917.4.diff

File 22917.4.diff, 2.9 KB (added by adamsilverstein, 12 years ago)

uses wp_is_large_network to set live count update defaults

  • wp-includes/ms-functions.php

     
    905905        delete_user_option( $user_id, 'user_level' );
    906906
    907907        do_action( 'wpmu_new_user', $user_id );
     908        if ( apply_filters( 'enable_live_network_user_counts', ! wp_is_large_network( 'users' ) ) ) // live update user count, unless large network see trac #22917
     909                wp_update_network_user_counts(); // user added, update network counts
    908910
    909911        return $user_id;
    910912}
     
    11341136        populate_options();
    11351137        populate_roles();
    11361138        $wp_roles->_init();
     1139        if ( apply_filters( 'enable_live_network_blog_counts', ! wp_is_large_network( 'sites' ) ) ) // live update blog count, unless large network - see trac #22917
     1140                wp_update_network_blog_counts(); // new blog added, update network counts
    11371141
    11381142        $url = untrailingslashit( $url );
    11391143
     
    18811885 *  @since 3.1.0
    18821886 */
    18831887function wp_update_network_counts() {
     1888        wp_update_network_user_counts();
     1889        wp_update_network_blog_counts();
     1890}
     1891
     1892/**
     1893 * Update the network-wide counts for users.
     1894 *
     1895 * @since 3.6.0
     1896 */
     1897function wp_update_network_user_counts() {
    18841898        global $wpdb;
    18851899
    1886         $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $wpdb->siteid) );
    1887         update_site_option( 'blog_count', $count );
    1888 
    18891900        $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
    18901901        update_site_option( 'user_count', $count );
    18911902}
    18921903
    18931904/**
     1905 * Update the network-wide counts for blogs.
     1906 *
     1907 * @since 3.6.0
     1908 */
     1909function wp_update_network_blog_counts() {
     1910        global $wpdb;
     1911
     1912        $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $wpdb->siteid ) );
     1913        update_site_option( 'blog_count', $count );
     1914}
     1915
     1916/**
    18941917 * Returns the space used by the current blog.
    18951918 *
    18961919 * @since 3.5.0
  • wp-admin/includes/ms.php

     
    122122                }
    123123
    124124                clean_blog_cache( $blog );
     125                if ( apply_filters( 'enable_live_network_blog_counts', ! wp_is_large_network( 'sites' ) ) ) // live update blog count, unless large network - see trac #22917
     126                        wp_update_network_blog_counts(); // blog deleted, update network counts
    125127        }
    126128
    127129        if ( $switch )
     
    171173        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
    172174
    173175        clean_user_cache( $user );
     176        if ( apply_filters( 'enable_live_network_user_counts', ! wp_is_large_network( 'users' ) ) ) // live update user count, unless large network see trac #22917
     177                wp_update_network_user_counts(); // user deleted, update network counts
    174178
    175179        // allow for commit transaction
    176180        do_action( 'deleted_user', $id );