Ticket #36935: 36935.9.diff
File 36935.9.diff, 5.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-site.php
218 218 * Getter. 219 219 * 220 220 * Allows current multisite naming conventions when getting properties. 221 * Allows access to extended site properties. 221 222 * 222 223 * @since 4.6.0 223 224 * @access public … … 235 236 return $this->site_id; 236 237 case 'network_id': 237 238 return (int) $this->site_id; 239 case 'blogname': 240 case 'siteurl': 241 case 'post_count': 242 case 'home': 243 if ( ! did_action( 'ms_loaded' ) ) { 244 return null; 245 } 246 $details = $this->get_details(); 247 return $details->$key; 238 248 } 239 249 240 250 return null; … … 244 254 * Isset-er. 245 255 * 246 256 * Allows current multisite naming conventions when checking for properties. 257 * Checks for extended site properties. 247 258 * 248 259 * @since 4.6.0 249 260 * @access public … … 258 269 case 'site_id': 259 270 case 'network_id': 260 271 return true; 272 case 'blogname': 273 case 'siteurl': 274 case 'post_count': 275 case 'home': 276 if ( ! did_action( 'ms_loaded' ) ) { 277 return false; 278 } 279 return true; 261 280 } 262 281 263 282 return false; … … 288 307 $this->$key = $value; 289 308 } 290 309 } 310 311 /** 312 * Retrieve the details for this site. 313 * 314 * This method is used internally to lazy-load the extended properties of a site. 315 * 316 * @since 4.6.0 317 * @access private 318 * 319 * @see WP_Site::__get() 320 * 321 * @return object A raw site object with all details included. 322 */ 323 private function get_details() { 324 $details = wp_cache_get( $this->blog_id, 'site-details' ); 325 326 if ( false === $details ) { 327 328 switch_to_blog( $this->blog_id ); 329 // Create a raw copy of the object for backwards compatibility with the filter below. 330 $details = new stdClass(); 331 foreach ( get_object_vars( $this ) as $key => $value ) { 332 $details->$key = $value; 333 } 334 $details->blogname = get_option( 'blogname' ); 335 $details->siteurl = get_option( 'siteurl' ); 336 $details->post_count = get_option( 'post_count' ); 337 $details->home = get_option( 'home' ); 338 restore_current_blog(); 339 340 $cache_details = true; 341 foreach ( array( 'blogname', 'siteurl', 'post_count', 'home' ) as $field ) { 342 if ( false === $details->$field ) { 343 $cache_details = false; 344 break; 345 } 346 } 347 348 if ( $cache_details ) { 349 wp_cache_set( $this->blog_id, $details, 'site-details' ); 350 } 351 } 352 353 /** 354 * Filters a site's extended properties. 355 * 356 * @since 4.6.0 357 * 358 * @param object $details The site details. 359 */ 360 $details = apply_filters( 'site_details', $details ); 361 362 return $details; 363 } 291 364 } -
src/wp-includes/load.php
509 509 wp_cache_init(); 510 510 511 511 if ( function_exists( 'wp_cache_add_global_groups' ) ) { 512 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', ' rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );512 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); 513 513 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 514 514 } 515 515 } -
src/wp-includes/ms-blogs.php
455 455 $domain_path_key = md5( $blog->domain . $blog->path ); 456 456 457 457 wp_cache_delete( $blog_id, 'sites' ); 458 wp_cache_delete( $blog_id, 'site-details' ); 458 459 wp_cache_delete( $blog_id , 'blog-details' ); 459 460 wp_cache_delete( $blog_id . 'short' , 'blog-details' ); 460 461 wp_cache_delete( $domain_path_key, 'blog-lookup' ); … … 822 823 if ( is_array( $global_groups ) ) { 823 824 wp_cache_add_global_groups( $global_groups ); 824 825 } else { 825 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );826 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) ); 826 827 } 827 828 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 828 829 } … … 893 894 if ( is_array( $global_groups ) ) { 894 895 wp_cache_add_global_groups( $global_groups ); 895 896 } else { 896 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );897 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) ); 897 898 } 898 899 wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); 899 900 } -
src/wp-includes/ms-settings.php
104 104 105 105 // Define upload directory constants 106 106 ms_upload_constants(); 107 108 /** 109 * Fires after the current site and network have been detected and loaded. 110 * 111 * @since 4.6.0 112 */ 113 do_action( 'ms_loaded' );