Ticket #12531: onlyimprove.patch
| File onlyimprove.patch, 3.1 KB (added by ocean90, 3 years ago) |
|---|
-
wp-admin/includes/ms.php
161 161 // allow for commit transaction 162 162 do_action('deleted_user', $id); 163 163 164 delete_site_transient( 'user_count' ); 165 164 166 return true; 165 167 } 166 168 … … 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-includes/ms-blogs.php
502 502 do_action( "make_ham_blog", $blog_id ); 503 503 } 504 504 505 delete_site_transient( 'blog_count' ); 506 505 507 return $value; 506 508 } 507 509 -
wp-includes/ms-functions.php
9 9 global $wpdb; 10 10 11 11 $stats['blogs'] = get_blog_count(); 12 $stats['users'] = get_user_count(); 12 13 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 … … 202 194 function get_user_count() { 203 195 global $wpdb; 204 196 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 } 197 $count = get_site_transient( 'user_count' ); 211 198 212 $count = get_site_option( "user_count" ); 199 if ( false !== $count ) 200 return $count; 213 201 202 $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); 203 204 set_site_transient( 'user_count', $count ); 205 214 206 return $count; 215 207 } 216 208 … … 220 212 if ( $id == 0 ) 221 213 $id = $wpdb->siteid; 222 214 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 } 215 $count = get_site_transient( 'user_count' ); 229 216 230 $count = get_site_option( "blog_count" ); 217 if ( false !== $count ) 218 return $count; 231 219 220 $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' AND mature = '0'", $id) ); 221 222 set_site_transient( 'blog_count', $count ); 223 232 224 return $count; 233 225 } 234 226 … … 836 828 837 829 restore_current_blog(); 838 830 do_action( 'wpmu_new_blog', $blog_id, $user_id ); 839 831 832 delete_site_transient( 'user_count' ); 833 840 834 return $blog_id; 841 835 } 842 836
