Ticket #18955: 18955.notoptions.2.diff
| File 18955.notoptions.2.diff, 3.9 KB (added by , 15 years ago) |
|---|
-
wp-includes/functions.php
473 473 $site_id = $wpdb->siteid; 474 474 475 475 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' ); 476 $existing_core_options = array(); 476 477 477 478 $core_options_in = "'" . implode("', '", $core_options) . "'"; 478 479 $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) ); 479 480 480 481 foreach ( $options as $option ) { 481 482 $key = $option->meta_key; 483 $existing_core_options[] = $key; 482 484 $cache_key = "{$site_id}:$key"; 483 485 $option->meta_value = maybe_unserialize( $option->meta_value ); 484 486 485 487 wp_cache_set( $cache_key, $option->meta_value, 'site-options' ); 486 488 } 489 490 $core_not_options = array_diff( $core_options, $existing_core_options ); 491 if ( ! empty( $core_not_options ) ) { 492 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 493 foreach( $core_not_options as $key ) 494 $notoptions[ $key ] = true; 495 496 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 497 } 487 498 } 488 499 489 500 /** … … 3791 3802 $value = get_option($option, $default); 3792 3803 } else { 3793 3804 $cache_key = "{$wpdb->siteid}:$option"; 3794 if ( $use_cache ) 3795 $value = wp_cache_get($cache_key, 'site-options'); 3805 if ( $use_cache ) { 3806 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 3807 if ( isset( $notoptions[ $cache_key ] ) ) 3808 return $default; 3796 3809 3810 $value = wp_cache_get( $cache_key, 'site-options' ); 3811 } 3812 3797 3813 if ( !isset($value) || (false === $value) ) { 3798 3814 $row = $wpdb->get_row( $wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ); 3799 3815 3800 3816 // Has to be get_row instead of get_var because of funkiness with 0, false, null values 3801 if ( is_object( $row ) ) 3817 if ( is_object( $row ) ) { 3802 3818 $value = $row->meta_value; 3803 else 3804 $value = $default; 3819 } else { 3820 $notoptions[ $cache_key ] = true; 3821 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 3822 return $default; 3823 } 3805 3824 3806 3825 $value = maybe_unserialize( $value ); 3807 3826 … … 3840 3859 } else { 3841 3860 $cache_key = "{$wpdb->siteid}:$option"; 3842 3861 3843 if ( false !== get_site_option( $option ) ) 3844 return false; 3862 // make sure the option doesn't already exist 3863 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 3864 if ( ! isset( $notoptions[ $cache_key ] ) ) 3865 if ( false !== get_site_option( $option ) ) 3866 return false; 3845 3867 3846 3868 $value = sanitize_option( $option, $value ); 3847 3869 wp_cache_set( $cache_key, $value, 'site-options' ); 3848 3870 3871 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); // yes, again... we need it to be fresh 3872 if ( isset( $notoptions[ $cache_key ] ) ) { 3873 unset( $notoptions[ $cache_key ] ); 3874 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 3875 } 3876 3849 3877 $_value = $value; 3850 3878 $value = maybe_serialize( $value ); 3851 $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );3879 $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) ); 3852 3880 $value = $_value; 3853 3881 } 3854 3882 … … 3933 3961 if ( !is_multisite() ) { 3934 3962 $result = update_option( $option, $value ); 3935 3963 } else { 3964 $cache_key = "{$wpdb->siteid}:$option"; 3965 3966 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 3967 if ( isset( $notoptions[ $cache_key ] ) ) { 3968 unset( $notoptions[ $cache_key ] ); 3969 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 3970 } 3971 3936 3972 $value = sanitize_option( $option, $value ); 3937 $cache_key = "{$wpdb->siteid}:$option";3938 3973 wp_cache_set( $cache_key, $value, 'site-options' ); 3939 3974 3940 3975 $_value = $value;
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)