Ticket #12531: 12531.6.2.patch
| File 12531.6.2.patch, 4.1 KB (added by ocean90, 3 years ago) |
|---|
-
wp-admin/includes/ms.php
76 76 77 77 update_blog_status( $blog_id, 'deleted', 1 ); 78 78 79 delete_site_transient( 'blog_count' ); 80 79 81 if ( $drop ) { 80 82 $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A ); 81 83 $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables ); … … 167 169 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); 168 170 169 171 clean_user_cache( $id ); 172 173 delete_site_transient( 'user_count' ); 170 174 171 175 // allow for commit transaction 172 176 do_action( 'deleted_user', $id ); … … 528 532 do_action( 'make_ham_user', $id ); 529 533 } 530 534 535 delete_site_transient( 'user_count' ); 536 531 537 return $value; 532 538 } 533 539 -
wp-includes/ms-blogs.php
508 508 do_action( "make_ham_blog", $blog_id ); 509 509 } 510 510 511 delete_site_transient( 'blog_count' ); 512 511 513 return $value; 512 514 } 513 515 -
wp-includes/ms-functions.php
11 11 global $wpdb; 12 12 13 13 $stats['blogs'] = get_blog_count(); 14 $stats['users'] = get_user_count(); 14 15 15 $count_ts = get_site_option( 'user_count_ts' );16 if ( time() - $count_ts > 3600 ) {17 $count = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->users" );18 update_site_option( 'user_count', $count );19 update_site_option( 'user_count_ts', time() );20 } else {21 $count = get_site_option( 'user_count' );22 }23 $stats['users'] = $count;24 16 return $stats; 25 17 } 26 18 … … 204 196 function get_user_count() { 205 197 global $wpdb; 206 198 207 $count_ts = get_site_option( "user_count_ts" ); 208 if ( time() - $count_ts > 3600 ) { 209 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") ); 210 update_site_option( "user_count", $count ); 211 update_site_option( "user_count_ts", time() ); 212 } 199 $count = get_site_transient( 'user_count' ); 200 if ( false !== $count ) 201 return $count; 213 202 214 $count = get_site_option( "user_count" ); 215 216 return $count; 203 $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); 204 set_site_transient( 'user_count', (int) $count ); 205 206 return (int) $count; 217 207 } 218 208 219 function get_blog_count( $ id = 0 ) {209 function get_blog_count( $site_id = 0 ) { 220 210 global $wpdb; 221 211 222 if ( $ id == 0 )223 $ id = $wpdb->siteid;212 if ( $site_id == 0 ) 213 $site_id = $wpdb->siteid; 224 214 225 $count _ts = get_site_option( "blog_count_ts");226 if ( time() - $count_ts > 3600 ) {227 $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) );228 update_site_option( "blog_count", $count );229 update_site_option( "blog_count_ts", time() );230 }215 $count = get_site_transient( 'blog_count' ); 216 if ( false !== $count ) 217 return $count; 218 219 $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'", $site_id) ); 220 set_site_transient( 'blog_count', (int) $count ); 231 221 232 $count = get_site_option( "blog_count" ); 233 234 return $count; 222 return (int) $count; 235 223 } 236 224 237 225 function get_blog_post( $blog_id, $post_id ) { … … 786 774 return false; 787 775 788 776 // Newly created users have no roles or caps until they are added to a blog. 789 update_user_option($user_id, 'capabilities', '');790 update_user_option($user_id, 'user_level', '');777 delete_user_option($user_id, 'capabilities' ); 778 delete_user_option($user_id, 'user_level' ); 791 779 792 780 do_action( 'wpmu_new_user', $user_id ); 781 782 delete_site_transient( 'user_count' ); 793 783 794 784 return $user_id; 795 785 } … … 838 828 restore_current_blog(); 839 829 do_action( 'wpmu_new_blog', $blog_id, $user_id ); 840 830 831 delete_site_transient( 'blog_count' ); 832 841 833 return $blog_id; 842 834 } 843 835
