336 | | if ( isset( $alloptions[$setting] ) ) { |
337 | | $value = $alloptions[$setting]; |
338 | | } else { |
339 | | $value = wp_cache_get( $setting, 'options' ); |
| 336 | if ( false === $value ) { |
| 337 | if ( defined( 'WP_INSTALLING' ) ) |
| 338 | $suppress = $wpdb->suppress_errors(); |
| 339 | // expected_slashed ($setting) |
| 340 | $row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1" ); |
| 341 | if ( defined( 'WP_INSTALLING' ) ) |
| 342 | $wpdb->suppress_errors($suppress); |
341 | | if ( false === $value ) { |
342 | | if ( defined( 'WP_INSTALLING' ) ) |
343 | | $suppress = $wpdb->suppress_errors(); |
344 | | // expected_slashed ($setting) |
345 | | $row = $wpdb->get_row( "SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1" ); |
346 | | if ( defined( 'WP_INSTALLING' ) ) |
347 | | $wpdb->suppress_errors($suppress); |
348 | | |
349 | | if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values |
350 | | $value = $row->option_value; |
351 | | wp_cache_add( $setting, $value, 'options' ); |
352 | | } else { // option does not exist, so we must cache its non-existence |
353 | | $notoptions[$setting] = true; |
354 | | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
355 | | return $default; |
356 | | } |
| 344 | if ( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values |
| 345 | $value = $row->option_value; |
| 346 | wp_cache_add( $setting, $value, 'options' ); |
| 347 | wp_cache_delete( 'all_options', 'options' ); |
| 348 | } else { // option does not exist, so we must cache its non-existence |
| 349 | $notoptions[$setting] = true; |
| 350 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 351 | return $default; |
403 | | * Retrieve all autoload options or all options, if no autoloaded ones exist. |
404 | | * |
405 | | * This is different from wp_load_alloptions() in that this function does not |
406 | | * cache its results and will retrieve all options from the database every time |
407 | | * |
408 | | * it is called. |
409 | | * |
410 | | * @since 1.0.0 |
411 | | * @package WordPress |
412 | | * @subpackage Option |
413 | | * @uses apply_filters() Calls 'pre_option_$optionname' hook with option value as parameter. |
414 | | * @uses apply_filters() Calls 'all_options' on options list. |
415 | | * |
416 | | * @return array List of all options. |
417 | | */ |
418 | | function get_alloptions() { |
419 | | global $wpdb; |
420 | | $show = $wpdb->hide_errors(); |
421 | | if ( !$options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) |
422 | | $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
423 | | $wpdb->show_errors($show); |
424 | | |
425 | | foreach ( (array) $options as $option ) { |
426 | | // "When trying to design a foolproof system, |
427 | | // never underestimate the ingenuity of the fools :)" -- Dougal |
428 | | if ( in_array( $option->option_name, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) |
429 | | $option->option_value = untrailingslashit( $option->option_value ); |
430 | | $value = maybe_unserialize( $option->option_value ); |
431 | | $all_options->{$option->option_name} = apply_filters( 'pre_option_' . $option->option_name, $value ); |
432 | | } |
433 | | return apply_filters( 'all_options', $all_options ); |
434 | | } |
435 | | |
436 | | /** |
437 | | * Loads and caches all autoloaded options, if available or all options. |
438 | | * |
439 | | * This is different from get_alloptions(), in that this function will cache the |
440 | | * options and will return the cached options when called again. |
441 | | * |
442 | | * @since 2.2.0 |
443 | | * @package WordPress |
444 | | * @subpackage Option |
445 | | * |
446 | | * @return array List all options. |
447 | | */ |
448 | | function wp_load_alloptions() { |
449 | | global $wpdb; |
450 | | |
451 | | $alloptions = wp_cache_get( 'alloptions', 'options' ); |
452 | | |
453 | | if ( !$alloptions ) { |
454 | | $suppress = $wpdb->suppress_errors(); |
455 | | if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) |
456 | | $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ); |
457 | | $wpdb->suppress_errors($suppress); |
458 | | $alloptions = array(); |
459 | | foreach ( (array) $alloptions_db as $o ) |
460 | | $alloptions[$o->option_name] = $o->option_value; |
461 | | wp_cache_add( 'alloptions', $alloptions, 'options' ); |
462 | | } |
463 | | return $alloptions; |
464 | | } |
465 | | |
466 | | /** |
525 | | $alloptions = wp_load_alloptions(); |
526 | | if ( isset( $alloptions[$option_name] ) ) { |
527 | | $alloptions[$option_name] = $newvalue; |
528 | | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
529 | | } else { |
530 | | wp_cache_set( $option_name, $newvalue, 'options' ); |
531 | | } |
| 456 | wp_cache_set( $option_name, $newvalue, 'options' ); |
| 457 | wp_cache_delete( 'all_options', 'options' ); |
586 | | if ( 'yes' == $autoload ) { |
587 | | $alloptions = wp_load_alloptions(); |
588 | | $alloptions[$name] = $value; |
589 | | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
590 | | } else { |
591 | | wp_cache_set( $name, $value, 'options' ); |
592 | | } |
| 512 | wp_cache_set( $name, $value, 'options' ); |
| 513 | wp_cache_delete( 'all_options', 'options'); |
629 | | if ( 'yes' == $option->autoload ) { |
630 | | $alloptions = wp_load_alloptions(); |
631 | | if ( isset( $alloptions[$name] ) ) { |
632 | | unset( $alloptions[$name] ); |
633 | | wp_cache_set( 'alloptions', $alloptions, 'options' ); |
634 | | } |
635 | | } else { |
636 | | wp_cache_delete( $name, 'options' ); |
637 | | } |
| 550 | wp_cache_delete( $name, 'options' ); |
| 551 | wp_cache_delete( 'all_options', 'options' ); |
| 552 | |
686 | | // If option is not in alloptions, it is not autoloaded and thus has a timeout |
687 | | $alloptions = wp_load_alloptions(); |
688 | | if ( !isset( $alloptions[$transient_option] ) ) { |
689 | | $transient_timeout = '_transient_timeout_' . $wpdb->escape($transient); |
690 | | if ( get_option($transient_timeout) < time() ) { |
| 601 | $transient_timeout = '_transient_timeout_' . $wpdb->escape($transient); |
| 602 | // TODO: Avoid timeout option request if option is autoloaded, |
| 603 | // autoloaded options don't have timeouts. |
| 604 | $timeout = get_option($transient_timeout); |
| 605 | if ( $timeout ) { |
| 606 | if ( $timeout < time() ) { |