diff --git wp-includes/option.php wp-includes/option.php
index 3df89c2..1bc49a3 100644
|
|
function get_site_option( $option, $default = false, $use_cache = true ) { |
767 | 767 | if ( false !== $pre ) |
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 ); |
772 | 777 | $value = get_option($option, $default); |
… |
… |
function get_site_option( $option, $default = false, $use_cache = true ) { |
784 | 789 | $value = maybe_unserialize( $value ); |
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 | } |
789 | 796 | } |
… |
… |
function get_site_option( $option, $default = false, $use_cache = true ) { |
813 | 820 | function add_site_option( $option, $value ) { |
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 | |
818 | 827 | if ( !is_multisite() ) { |
… |
… |
function add_site_option( $option, $value ) { |
820 | 829 | } else { |
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_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 | |
829 | 842 | $_value = $value; |
830 | 843 | $value = maybe_serialize( $value ); |
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 | |
835 | 855 | if ( $result ) { |
… |
… |
function delete_site_option( $option ) { |
901 | 921 | function update_site_option( $option, $value ) { |
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 ); |
906 | 928 | |
… |
… |
function update_site_option( $option, $value ) { |
910 | 932 | if ( false === $oldvalue ) |
911 | 933 | return add_site_option( $option, $value ); |
912 | 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 | } |
| 940 | |
913 | 941 | if ( !is_multisite() ) { |
914 | 942 | $result = update_option( $option, $value ); |
915 | 943 | } else { |