Ticket #12531: 12531.4.patch
| File 12531.4.patch, 7.7 KB (added by ocean90, 3 years ago) |
|---|
-
wp-admin/admin.php
37 37 * 38 38 * @since 2.8.4b 39 39 */ 40 $c = get_blog_count(); 40 $c = ms_count_blogs(); 41 $c = $c->active; 41 42 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { 42 43 require_once( ABSPATH . WPINC . '/http.php' ); 43 44 $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); -
wp-admin/includes/ms.php
160 160 161 161 // allow for commit transaction 162 162 do_action('deleted_user', $id); 163 164 delete_site_transient( 'user_count' ); 163 165 164 166 return true; 165 167 } … … 497 499 else 498 500 do_action( "make_ham_user", $id ); 499 501 } 500 502 503 delete_site_transient( 'user_count' ); 504 501 505 return $value; 502 506 } 503 507 -
wp-admin/ms-admin.php
18 18 wp_die( __('You do not have permission to access this page.') ); 19 19 20 20 global $wpdb; 21 $c_users = get_user_count();22 $c_blogs = get_blog_count();21 $c_users = ms_count_users(); 22 $c_blogs = ms_count_blogs(); 23 23 24 $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users) );25 $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs) );24 $user_text = sprintf( _n( '%s user', '%s users', $c_users->active ), number_format_i18n( $c_users->active ) ); 25 $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs->active ), number_format_i18n( $c_blogs->active ) ); 26 26 27 27 $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); 28 28 ?> -
wp-includes/ms-blogs.php
501 501 else 502 502 do_action( "make_ham_blog", $blog_id ); 503 503 } 504 505 delete_site_transient( 'blog_count' ); 504 506 505 507 return $value; 506 508 } -
wp-includes/ms-deprecated.php
24 24 } 25 25 26 26 /** 27 * @since unknown 28 * @deprecated 3.0.0 29 * @deprecated Use ms_count_blogs() 30 * @see ms_count_blogs() 31 */ 32 function get_blog_count( $id = '' ) { 33 _deprecated_function( __FUNCTION__, '3.0', 'ms_count_blogs()' ); 34 35 $count = ms_count_blogs( $id ); 36 37 return $count->active; 38 } 39 40 /** 41 * @since unknown 42 * @deprecated 3.0.0 43 * @deprecated Use ms_count_users() 44 * @see ms_count_users() 45 */ 46 function get_user_count() { 47 _deprecated_function( __FUNCTION__, '3.0', 'ms_count_users()' ); 48 49 $count = ms_count_users(); 50 51 return $count->active; 52 } 53 54 /** 27 55 * Determine if user is a site admin. 28 56 * 29 57 * Plugins should use is_multisite() instead of checking if this function exists -
wp-includes/ms-functions.php
6 6 */ 7 7 8 8 function get_sitestats() { 9 global $wpdb; 9 $count_blog = ms_count_blogs(); 10 $count_users = ms_count_users(); 11 $stats['blogs'] = $count_blog->active; 12 $stats['users'] = $count_users->active; 10 13 11 $stats['blogs'] = get_blog_count();12 13 $count_ts = get_site_option( 'user_count_ts' );14 if ( time() - $count_ts > 3600 ) {15 $count = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->users" );16 update_site_option( 'user_count', $count );17 update_site_option( 'user_count_ts', time() );18 } else {19 $count = get_site_option( 'user_count' );20 }21 $stats['users'] = $count;22 14 return $stats; 23 15 } 24 16 … … 199 191 return array_slice( $most_active, 0, $num ); 200 192 } 201 193 202 function get_user_count() { 194 195 /** 196 * Retrieve total users 197 * 198 * The properties of the returned object contain the 'spam' and 'deleted' 199 * users. Those properties contain the amount of users that match 200 * the status. The 'active' property contains the integer of users, which are not 201 * 'spam' and 'deleted'. The 'total' property contains the integer of total users. 202 * 203 * The user stats are cached and then retrieved, if they already exist in the 204 * cache. 205 * 206 * @since 3.0.0 207 * 208 * @return object User stats. 209 */ 210 function ms_count_users() { 203 211 global $wpdb; 212 213 $count = get_site_transient( 'user_count' ); 214 215 if ( false !== $count ) 216 return $count; 217 218 $count['active'] = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); 219 $count['total'] = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users" ); 220 $count['spam'] = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '1'" ); 221 $count['deleted'] = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE deleted = '1'" ); 204 222 205 $count_ts = get_site_option( "user_count_ts" ); 206 if ( time() - $count_ts > 3600 ) { 207 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") ); 208 update_site_option( "user_count", $count ); 209 update_site_option( "user_count_ts", time() ); 210 } 211 212 $count = get_site_option( "user_count" ); 213 223 $count = (object) $count; 224 set_site_transient( 'user_count', $count ); 225 214 226 return $count; 215 227 } 216 228 217 function get_blog_count( $id = 0 ) { 229 230 /** 231 * Retrieve total blogs 232 * 233 * The properties of the returned object contain the 'spam', 'deleted' 234 * and 'archived' blogs. Those properties contain the amount of blogs that match 235 * the status. The 'active' property contains the integer of blogs, which are not 236 * 'spam', 'deleted' and 'archived'. The 'total' property contains the integer of 237 * total blogs. 238 * 239 * The blog stats are cached and then retrieved, if they already exist in the 240 * cache. 241 * 242 * @since 3.0.0 243 * 244 * @param int $id Optional. Site ID. 245 * @return object Blog stats. 246 */ 247 function ms_count_blogs( $id = 0 ) { 218 248 global $wpdb; 219 249 220 250 if ( $id == 0 ) 221 251 $id = $wpdb->siteid; 222 252 223 $count_ts = get_site_option( "blog_count_ts" ); 224 if ( time() - $count_ts > 3600 ) { 225 $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'", $id) ); 226 update_site_option( "blog_count", $count ); 227 update_site_option( "blog_count_ts", time() ); 228 } 253 $count = get_site_transient( 'blog_count' ); 254 255 if ( false !== $count ) 256 return $count; 257 258 $count['active'] = $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'", $id) ); 259 $count['total'] = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d", $id) ); 260 $count['spam'] = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '1'", $id) ); 261 $count['deleted'] = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND deleted = '1'", $id) ); 262 $count['archived'] = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND archived = '1'", $id) ); 229 263 230 $count = get_site_option( "blog_count" ); 231 264 $count = (object) $count; 265 set_site_transient( 'blog_count', $count ); 266 232 267 return $count; 233 268 } 234 269 … … 789 824 update_user_option($user_id, 'user_level', ''); 790 825 791 826 do_action( 'wpmu_new_user', $user_id ); 827 828 delete_site_transient( 'user_count' ); 792 829 793 830 return $user_id; 794 831 }
