| 1 | --- Patch file for get_blog_details caching fix |
|---|
| 2 | --- wp-includes/ms-blogs.php |
|---|
| 3 | |
|---|
| 4 | @@ function get_blog_details( $fields = null, $get_all = true ) { |
|---|
| 5 | - $blog_id = (int) $fields; |
|---|
| 6 | - $details = wp_cache_get( $blog_id, 'blog-details' ); |
|---|
| 7 | + $blog_id = (int) $fields; |
|---|
| 8 | + $cache_key = $get_all ? $blog_id . '-full' : $blog_id . '-short'; |
|---|
| 9 | + $details = wp_cache_get( $cache_key, 'blog-details' ); |
|---|
| 10 | |
|---|
| 11 | if ( false === $details ) { |
|---|
| 12 | global $wpdb; |
|---|
| 13 | |
|---|
| 14 | - if ( $get_all ) { |
|---|
| 15 | + if ( $get_all ) { |
|---|
| 16 | $details = $wpdb->get_row( |
|---|
| 17 | $wpdb->prepare( |
|---|
| 18 | "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", |
|---|
| 19 | $blog_id |
|---|
| 20 | ) |
|---|
| 21 | ); |
|---|
| 22 | } else { |
|---|
| 23 | $details = $wpdb->get_row( |
|---|
| 24 | $wpdb->prepare( |
|---|
| 25 | "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details (short) */", |
|---|
| 26 | $blog_id |
|---|
| 27 | ) |
|---|
| 28 | ); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | if ( null === $details ) { |
|---|
| 32 | return false; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | $details->blog_id = (int) $details->blog_id; |
|---|
| 36 | |
|---|
| 37 | // Add details to cache. |
|---|
| 38 | - wp_cache_set( $blog_id, $details, 'blog-details' ); |
|---|
| 39 | + wp_cache_set( $cache_key, $details, 'blog-details' ); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | return $details; |
|---|
| 43 | } |
|---|