Changeset 25043
- Timestamp:
- 08/16/2013 10:41:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r24760 r25043 768 768 return $pre; 769 769 770 // prevent non-existent options from triggering multiple queries 771 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 772 if ( isset( $notoptions[$option] ) ) 773 return apply_filters( 'default_site_option_' . $option, $default ); 774 770 775 if ( ! is_multisite() ) { 771 776 $default = apply_filters( 'default_site_option_' . $option, $default ); … … 785 790 wp_cache_set( $cache_key, $value, 'site-options' ); 786 791 } else { 792 $notoptions[$option] = true; 793 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 787 794 $value = apply_filters( 'default_site_option_' . $option, $default ); 788 795 } … … 814 821 global $wpdb; 815 822 823 wp_protect_special_option( $option ); 824 816 825 $value = apply_filters( 'pre_add_site_option_' . $option, $value ); 817 826 … … 821 830 $cache_key = "{$wpdb->siteid}:$option"; 822 831 823 if ( false !== get_site_option( $option ) ) 824 return false; 832 // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query 833 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 834 if ( ! is_array( $notoptions ) || ! isset( $notoptions[$option] ) ) 835 if ( false !== get_site_option( $option ) ) 836 return false; 825 837 826 838 $value = sanitize_option( $option, $value ); 839 827 840 wp_cache_set( $cache_key, $value, 'site-options' ); 828 841 … … 831 844 $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) ); 832 845 $value = $_value; 846 847 // This option exists now 848 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); // yes, again... we need it to be fresh 849 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { 850 unset( $notoptions[$option] ); 851 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 852 } 833 853 } 834 854 … … 902 922 global $wpdb; 903 923 924 wp_protect_special_option( $option ); 925 904 926 $oldvalue = get_site_option( $option ); 905 927 $value = apply_filters( 'pre_update_site_option_' . $option, $value, $oldvalue ); … … 910 932 if ( false === $oldvalue ) 911 933 return add_site_option( $option, $value ); 934 935 $notoptions = wp_cache_get( 'notoptions', 'site-options' ); 936 if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { 937 unset( $notoptions[$option] ); 938 wp_cache_set( 'notoptions', $notoptions, 'site-options' ); 939 } 912 940 913 941 if ( !is_multisite() ) {
Note: See TracChangeset
for help on using the changeset viewer.