Ticket #45839: 45839.diff
File 45839.diff, 4.7 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/schema.php
576 576 $autoload = 'yes'; 577 577 } 578 578 579 if ( is_array( $value ) ) { 580 $value = serialize( $value ); 581 } 582 if ( ! empty( $insert ) ) { 583 $insert .= ', '; 584 } 585 $insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload ); 579 add_option( $option, $value, '', $autoload ); 586 580 } 587 581 588 if ( ! empty( $insert ) ) {589 $wpdb->query( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared590 }591 582 592 583 // In case it is set, but blank, update "home". 593 584 if ( ! __get_option( 'home' ) ) { -
src/wp-includes/class-wp-site.php
310 310 * @return stdClass A raw site object with all details included. 311 311 */ 312 312 private function get_details() { 313 $ details = wp_cache_get( $this->blog_id, 'site-details' );313 $site_details = array( 'blogname', 'siteurl', 'post_count', 'home' ); 314 314 315 if ( false === $details ) { 315 // Create a raw copy of the object for backwards compatibility with the filter below. 316 $details = new stdClass(); 317 foreach ( get_object_vars( $this ) as $key => $value ) { 318 $details->$key = $value; 319 } 316 320 317 switch_to_blog( $this->blog_id ); 318 // Create a raw copy of the object for backwards compatibility with the filter below. 319 $details = new stdClass(); 320 foreach ( get_object_vars( $this ) as $key => $value ) { 321 $details->$key = $value; 321 foreach ( $site_details as $site_detail ) { 322 $details->$site_detail = get_site_meta( $this->blog_id, $site_detail, true ); 323 if ( false === $details->$site_detail ){ 324 $details->$site_detail = get_blog_option( $this->blog_id, $site_detail ); 322 325 } 323 $details->blogname = get_option( 'blogname' );324 $details->siteurl = get_option( 'siteurl' );325 $details->post_count = get_option( 'post_count' );326 $details->home = get_option( 'home' );327 restore_current_blog();328 329 wp_cache_set( $this->blog_id, $details, 'site-details' );330 326 } 331 327 332 328 /** This filter is documented in wp-includes/ms-blogs.php */ -
src/wp-includes/ms-blogs.php
1112 1112 'upload_path' => get_network_option( $network->id, 'ms_files_rewriting' ) ? UPLOADBLOGSDIR . "/{$site->id}/files" : get_blog_option( $network->site_id, 'upload_path' ), 1113 1113 'blog_public' => (int) $site->public, 1114 1114 'WPLANG' => get_network_option( $network->id, 'WPLANG' ), 1115 'post_count' => 0, 1115 1116 ), 1116 1117 $args['options'] 1117 1118 ) … … 2309 2310 2310 2311 update_blog_option( $site_id, 'blog_public', $public ); 2311 2312 } 2313 2314 2315 function update_option_to_meta( $value, $old_value, $option ){ 2316 update_site_meta( get_current_blog_id(), $option, $value, $old_value ); 2317 } 2318 2319 function add_option_to_meta( $option, $value ){ 2320 add_site_meta( get_current_blog_id(), $option, $value ); 2321 } 2322 2323 function delete_option_to_meta( $option ){ 2324 delete_site_meta( get_current_blog_id(), $option ); 2325 } 2326 2327 function load_from_blog_meta( $value, $option ){ 2328 return get_site_meta( get_current_blog_id(), $option, true ); 2329 } -
src/wp-includes/ms-default-filters.php
103 103 remove_filter( 'option_home', '_config_wp_home' ); 104 104 105 105 // Some options changes should trigger site details refresh. 106 add_action( 'update_option_blogname', 'clean_site_details_cache', 10, 0 ); 107 add_action( 'update_option_siteurl', 'clean_site_details_cache', 10, 0 ); 108 add_action( 'update_option_post_count', 'clean_site_details_cache', 10, 0 ); 109 add_action( 'update_option_home', 'clean_site_details_cache', 10, 0 ); 106 $site_details = array( 'blogname', 'siteurl', 'post_count', 'home' ); 107 foreach( $site_details as $site_detail ){ 108 add_action( 'update_option_' . $site_detail, 'update_option_to_meta', 8, 3 ); 109 add_action( 'add_option_' . $site_detail, 'add_option_to_meta', 8, 2 ); 110 add_action( 'delete_option_' . $site_detail, 'delete_option_to_meta', 8, 1 ); 111 add_filter( 'pre_option_' . $site_detail, 'load_from_blog_meta', 8, 2 ); 112 } 110 113 111 114 // If the network upgrade hasn't run yet, assume ms-files.php rewriting is used. 112 115 add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );