| 673 | | // Try priming the new cache from the old cache |
| 674 | | if ( false === $blogs ) { |
| 675 | | $cache_suffix = $all ? '_all' : '_short'; |
| 676 | | $blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' ); |
| 677 | | if ( is_array( $blogs ) ) { |
| 678 | | $blogs = array_keys( $blogs ); |
| 679 | | if ( $all ) |
| 680 | | wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' ); |
| 681 | | } |
| | 675 | $blogs = array(); |
| | 676 | |
| | 677 | if ( isset( $userkeys[ $wpdb->base_prefix . 'capabilities' ] ) ) { |
| | 678 | $blogs[] = 1; |
| | 679 | unset( $userkeys[ $wpdb->base_prefix . 'capabilities' ] ); |
| 690 | | $blogs = $match = array(); |
| 691 | | $prefix_length = strlen( $wpdb->base_prefix ); |
| 692 | | foreach ( $userkeys as $key ) { |
| 693 | | if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix ) |
| 694 | | continue; |
| 695 | | if ( substr($key, -12, 12) != 'capabilities' ) |
| 696 | | continue; |
| 697 | | if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) { |
| 698 | | if ( count( $match ) > 2 ) |
| 699 | | $blogs[] = (int) $match[ 2 ]; |
| 700 | | else |
| 701 | | $blogs[] = 1; |
| 702 | | } |
| 703 | | } |
| 704 | | wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' ); |
| | 684 | foreach ( $userkeys as $key ) { |
| | 685 | if ( 'capabilities' !== substr( $key, -12 ) ) |
| | 686 | continue; |
| | 687 | if ( 0 !== strpos( $key, $wpdb->base_prefix ) ) |
| | 688 | continue; |
| | 689 | $key = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key ); |
| | 690 | if ( is_numeric( $key ) ) |
| | 691 | $blogs[] = (int) $key; |