diff --git wp-includes/option.php wp-includes/option.php
index 6134606..ee85fb0 100644
|
|
function get_option( $option, $default = false ) { |
51 | 51 | |
52 | 52 | if ( ! defined( 'WP_INSTALLING' ) ) { |
53 | 53 | // prevent non-existent options from triggering multiple queries |
54 | | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 54 | if ( wp_using_ext_object_cache() ) { |
| 55 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 56 | } else { |
| 57 | // don't attempt to look for 'notoptions_cache' in notoptions itself |
| 58 | if ( $option == 'notoptions_cache' ) { |
| 59 | $notoptions = array(); // treat as if we don't know anything |
| 60 | } else { |
| 61 | $notoptions = get_option( 'notoptions_cache', array() ); |
| 62 | } |
| 63 | } |
55 | 64 | if ( isset( $notoptions[ $option ] ) ) { |
56 | 65 | /** |
57 | 66 | * Filter the default value for an option. |
… |
… |
function get_option( $option, $default = false ) { |
81 | 90 | $value = $row->option_value; |
82 | 91 | wp_cache_add( $option, $value, 'options' ); |
83 | 92 | } else { // option does not exist, so we must cache its non-existence |
84 | | $notoptions[$option] = true; |
85 | | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 93 | if ( $option != 'notoptions_cache' ) { |
| 94 | $notoptions[$option] = true; |
| 95 | if ( wp_using_ext_object_cache() ) { |
| 96 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 97 | } else { |
| 98 | update_option( 'notoptions_cache', $notoptions ); |
| 99 | } |
| 100 | } |
86 | 101 | |
87 | 102 | /** This filter is documented in wp-includes/option.php */ |
88 | 103 | return apply_filters( 'default_option_' . $option, $default ); |
… |
… |
function wp_load_alloptions() { |
172 | 187 | foreach ( (array) $alloptions_db as $o ) { |
173 | 188 | $alloptions[$o->option_name] = $o->option_value; |
174 | 189 | } |
| 190 | |
| 191 | // if this is one of those pageload where notoptions_cache isn't set, we insert it into the database directly, and append its default value i.e. empty array to $alloptions |
| 192 | if ( ! isset( $alloptions['notoptions_cache'] ) ) { |
| 193 | $wpdb->insert( $wpdb->options, array( 'option_name' => 'notoptions_cache', 'option_value' => serialize( array() ) ), array( '%s', '%s' ) ); |
| 194 | $alloptions['notoptions_cache'] = array(); |
| 195 | } |
| 196 | |
175 | 197 | if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) |
176 | 198 | wp_cache_add( 'alloptions', $alloptions, 'options' ); |
177 | 199 | } |
… |
… |
function update_option( $option, $value ) { |
288 | 310 | if ( ! $result ) |
289 | 311 | return false; |
290 | 312 | |
291 | | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 313 | if ( wp_using_ext_object_cache() ) { |
| 314 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 315 | } else { |
| 316 | $notoptions = get_option( 'notoptions_cache', array() ); |
| 317 | } |
292 | 318 | if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { |
293 | 319 | unset( $notoptions[$option] ); |
294 | | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 320 | if ( wp_using_ext_object_cache() ) { |
| 321 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 322 | } else { |
| 323 | update_option( 'notoptions_cache', $notoptions ); |
| 324 | } |
295 | 325 | } |
296 | 326 | |
297 | 327 | if ( ! defined( 'WP_INSTALLING' ) ) { |
… |
… |
function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) |
367 | 397 | $value = sanitize_option( $option, $value ); |
368 | 398 | |
369 | 399 | // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query |
370 | | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 400 | if ( wp_using_ext_object_cache() ) { |
| 401 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 402 | } else { |
| 403 | $notoptions = get_option( 'notoptions_cache', array() ); |
| 404 | } |
371 | 405 | if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) |
372 | 406 | if ( false !== get_option( $option ) ) |
373 | 407 | return false; |
… |
… |
function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) |
400 | 434 | } |
401 | 435 | |
402 | 436 | // This option exists now |
403 | | $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh |
| 437 | if ( wp_using_ext_object_cache() ) { |
| 438 | $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh |
| 439 | } else { |
| 440 | $notoptions = get_option( 'notoptions_cache', array() ); |
| 441 | } |
404 | 442 | if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) { |
405 | 443 | unset( $notoptions[$option] ); |
406 | | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 444 | if ( wp_using_ext_object_cache() ) { |
| 445 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 446 | } else { |
| 447 | update_option( 'notoptions_cache', $notoptions ); |
| 448 | } |
407 | 449 | } |
408 | 450 | |
409 | 451 | /** |