Ticket #18955: 18955.notoptions.diff
| File 18955.notoptions.diff, 2.8 KB (added by duck_, 19 months ago) |
|---|
-
wp-includes/functions.php
3791 3791 $value = get_option($option, $default); 3792 3792 } else { 3793 3793 $cache_key = "{$wpdb->siteid}:$option"; 3794 if ( $use_cache ) 3795 $value = wp_cache_get($cache_key, 'site-options'); 3794 if ( $use_cache ) { 3795 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 3796 if ( isset( $notoptions[ $cache_key ] ) ) 3797 return $default; 3796 3798 3799 $value = wp_cache_get( $cache_key, 'site-options' ); 3800 } 3801 3797 3802 if ( !isset($value) || (false === $value) ) { 3798 3803 $row = $wpdb->get_row( $wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ); 3799 3804 3800 3805 // Has to be get_row instead of get_var because of funkiness with 0, false, null values 3801 if ( is_object( $row ) ) 3806 if ( is_object( $row ) ) { 3802 3807 $value = $row->meta_value; 3803 else 3804 $value = $default; 3808 } else { 3809 $notoptions[ $cache_key ] = true; 3810 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 3811 return $default; 3812 } 3805 3813 3806 3814 $value = maybe_unserialize( $value ); 3807 3815 … … 3840 3848 } else { 3841 3849 $cache_key = "{$wpdb->siteid}:$option"; 3842 3850 3843 if ( false !== get_site_option( $option ) ) 3844 return false; 3851 // make sure the option doesn't already exist 3852 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 3853 if ( ! isset( $notoptions[ $cache_key ] ) ) 3854 if ( false !== get_site_option( $option ) ) 3855 return false; 3845 3856 3846 3857 $value = sanitize_option( $option, $value ); 3847 3858 wp_cache_set( $cache_key, $value, 'site-options' ); 3848 3859 3860 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); // yes, again... we need it to be fresh 3861 if ( isset( $notoptions[ $cache_key ] ) ) { 3862 unset( $notoptions[ $cache_key ] ); 3863 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 3864 } 3865 3849 3866 $_value = $value; 3850 3867 $value = maybe_serialize( $value ); 3851 $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );3868 $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) ); 3852 3869 $value = $_value; 3853 3870 } 3854 3871 … … 3933 3950 if ( !is_multisite() ) { 3934 3951 $result = update_option( $option, $value ); 3935 3952 } else { 3953 $cache_key = "{$wpdb->siteid}:$option"; 3954 3955 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 3956 if ( isset( $notoptions[ $cache_key ] ) ) { 3957 unset( $notoptions[ $cache_key ] ); 3958 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 3959 } 3960 3936 3961 $value = sanitize_option( $option, $value ); 3937 $cache_key = "{$wpdb->siteid}:$option";3938 3962 wp_cache_set( $cache_key, $value, 'site-options' ); 3939 3963 3940 3964 $_value = $value;
