Changeset 13126
- Timestamp:
- 02/13/2010 11:09:54 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/blogs.php
r13125 r13126 75 75 * 76 76 * @since 3.0 77 * @param int $blog_id Blog ID77 * @param int|string|array $fields A blog ID, a blog name, or an array of fields to query against. 78 78 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true. 79 79 * @return object Blog details. 80 80 */ 81 function get_blog_details( $blog_id, $get_all = true ) { 82 global $wpdb; 83 84 if ( !is_numeric( $blog_id ) ) 85 $blog_id = get_id_from_blogname( $blog_id ); 81 function get_blog_details( $fields, $get_all = true ) { 82 global $wpdb; 83 84 if ( is_array($fields ) ) { 85 if ( isset($fields['blog_id']) ) { 86 $blog_id = $fields['blog_id']; 87 } elseif ( isset($fields['domain']) && isset($fields['path']) ) { 88 $key = md5( $fields['domain'] . $fields['path'] ); 89 $blog = wp_cache_get($key, 'blog-lookup'); 90 if ( false !== $blog ) 91 return $blog; 92 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) ); 93 if ( $blog ) { 94 wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details'); 95 $blog_id = $blog->blog_id; 96 } else { 97 return false; 98 } 99 } elseif ( isset($fields['domain']) && is_subdomain_install() ) { 100 $key = md5( $fields['domain'] ); 101 $blog = wp_cache_get($key, 'blog-lookup'); 102 if ( false !== $blog ) 103 return $blog; 104 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) ); 105 if ( $blog ) { 106 wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details'); 107 $blog_id = $blog->blog_id; 108 } else { 109 return false; 110 } 111 } else { 112 return false; 113 } 114 } else { 115 if ( !is_numeric( $fields ) ) 116 $blog_id = get_id_from_blogname( $fields ); 117 else 118 $blog_id = $fields; 119 } 86 120 87 121 $blog_id = (int) $blog_id; … … 101 135 } 102 136 103 $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 104 if ( ! $details ) { 105 wp_cache_set( $blog_id . $all, -1, 'blog-details' ); 106 return false; 137 // Try the other cache. 138 if ( $get_all ) { 139 $details = wp_cache_get( $blog_id . 'short', 'blog-details' ); 140 } else { 141 $details = wp_cache_get( $blog_id, 'blog-details' ); 142 // If short was requested and full cache is set, we can return. 143 if ( $details ) { 144 if ( ! is_object( $details ) ) { 145 if ( $details == -1 ) 146 return false; 147 else 148 // Clear old pre-serialized objects. Cache clients do better with that. 149 wp_cache_delete( $blog_id . $all, 'blog-details' ); 150 } 151 return $details; 152 } 153 } 154 155 if ( !$details ) { 156 $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 157 if ( ! $details ) { 158 // Set the full cache. 159 wp_cache_set( $blog_id, -1, 'blog-details' ); 160 return false; 161 } 107 162 } 108 163 -
trunk/wp-includes/ms-settings.php
r13065 r13126 49 49 $current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' ); 50 50 if ( !$current_blog ) { 51 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domain ));51 $current_blog = get_blog_details( array('domain' => $domain), false ); 52 52 if ( $current_blog ) 53 53 wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' ); … … 68 68 $current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' ); 69 69 if ( ! $current_blog ) { 70 $current_blog = $ wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domain, $path ));70 $current_blog = $current_blog = get_blog_details( array('domain' => $domain, 'path' => $path ), false ); 71 71 if ( $current_blog ) 72 72 wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' ); … … 92 92 exit; 93 93 } 94 $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ));94 $current_blog = get_blog_details( array('domain' => $current_site->domain, 'path' => $current_site->path), false ); 95 95 } 96 96 if ( ! $current_blog || ! $current_site ) -
trunk/wp-settings.php
r13125 r13126 60 60 wp_set_lang_dir(); 61 61 62 // Includeearly WordPress files.62 // Load early WordPress files. 63 63 require( ABSPATH . WPINC . '/compat.php' ); 64 64 require( ABSPATH . WPINC . '/functions.php' ); … … 73 73 // Start the WordPress object cache, or an external object cache if the drop-in is present. 74 74 wp_start_object_cache(); 75 76 // Load early WordPress files. 77 require( ABSPATH . WPINC . '/plugin.php' ); 78 require( ABSPATH . WPINC . '/default-filters.php' ); 79 include_once( ABSPATH . WPINC . '/pomo/mo.php' ); 75 80 76 81 // Initialize multisite if enabled. … … 79 84 require( ABSPATH . WPINC . '/ms-settings.php' ); 80 85 } 81 82 // Load early WordPress files.83 require( ABSPATH . WPINC . '/plugin.php' );84 require( ABSPATH . WPINC . '/default-filters.php' );85 include_once( ABSPATH . WPINC . '/pomo/mo.php' );86 86 87 87 // Stop most of WordPress from being loaded if we just want the basics.
Note: See TracChangeset
for help on using the changeset viewer.