| 1 | Index: wp-includes/user.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/user.php (revision 18921) |
|---|
| 4 | +++ wp-includes/user.php (working copy) |
|---|
| 5 | @@ -665,45 +665,29 @@ |
|---|
| 6 | } |
|---|
| 7 | |
|---|
| 8 | // Logged out users can't have blogs |
|---|
| 9 | - if ( 0 === $id ) |
|---|
| 10 | + if ( empty( $id ) ) |
|---|
| 11 | return false; |
|---|
| 12 | |
|---|
| 13 | - $blogs = wp_cache_get( 'blogs_of_user-' . $id, 'users' ); |
|---|
| 14 | + $userkeys = get_user_meta( (int) $id ); |
|---|
| 15 | + if ( empty( $userkeys ) ) |
|---|
| 16 | + return false; |
|---|
| 17 | + $userkeys = array_keys( $userkeys ); |
|---|
| 18 | |
|---|
| 19 | - // Try priming the new cache from the old cache |
|---|
| 20 | - if ( false === $blogs ) { |
|---|
| 21 | - $cache_suffix = $all ? '_all' : '_short'; |
|---|
| 22 | - $blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' ); |
|---|
| 23 | - if ( is_array( $blogs ) ) { |
|---|
| 24 | - $blogs = array_keys( $blogs ); |
|---|
| 25 | - if ( $all ) |
|---|
| 26 | - wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' ); |
|---|
| 27 | + $blogs = array(); |
|---|
| 28 | + foreach ( $userkeys as $key ) { |
|---|
| 29 | + if ( $key === $wpdb->base_prefix . 'capabilities' ) { |
|---|
| 30 | + $blogs[] = 1; |
|---|
| 31 | + continue; |
|---|
| 32 | } |
|---|
| 33 | + if ( 'capabilities' !== substr( $key, -12 ) ) |
|---|
| 34 | + continue; |
|---|
| 35 | + if ( 0 !== strpos( $key, $wpdb->base_prefix ) ) |
|---|
| 36 | + continue; |
|---|
| 37 | + $key = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key ); |
|---|
| 38 | + if ( is_numeric( $key ) ) |
|---|
| 39 | + $blogs[] = (int) $key; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | - if ( false === $blogs ) { |
|---|
| 43 | - $userkeys = get_user_meta( (int) $id ); |
|---|
| 44 | - if ( empty( $userkeys ) ) |
|---|
| 45 | - return false; |
|---|
| 46 | - $userkeys = array_keys( $userkeys ); |
|---|
| 47 | - |
|---|
| 48 | - $blogs = $match = array(); |
|---|
| 49 | - $prefix_length = strlen( $wpdb->base_prefix ); |
|---|
| 50 | - foreach ( $userkeys as $key ) { |
|---|
| 51 | - if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) |
|---|
| 52 | - continue; |
|---|
| 53 | - if ( substr($key, -12, 12) != 'capabilities' ) |
|---|
| 54 | - continue; |
|---|
| 55 | - if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { |
|---|
| 56 | - if ( count( $match ) > 2 ) |
|---|
| 57 | - $blogs[] = (int) $match[ 2 ]; |
|---|
| 58 | - else |
|---|
| 59 | - $blogs[] = 1; |
|---|
| 60 | - } |
|---|
| 61 | - } |
|---|
| 62 | - wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' ); |
|---|
| 63 | - } |
|---|
| 64 | - |
|---|
| 65 | $blog_deets = array(); |
|---|
| 66 | foreach ( (array) $blogs as $blog_id ) { |
|---|
| 67 | $blog = get_blog_details( $blog_id ); |
|---|
| 68 | @@ -1153,7 +1137,6 @@ |
|---|
| 69 | wp_cache_delete($user->user_login, 'userlogins'); |
|---|
| 70 | wp_cache_delete($user->user_email, 'useremail'); |
|---|
| 71 | wp_cache_delete($user->user_nicename, 'userslugs'); |
|---|
| 72 | - wp_cache_delete('blogs_of_user-' . $id, 'users'); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | /** |
|---|