Make WordPress Core


Ignore:
Timestamp:
07/07/2007 04:08:04 AM (17 years ago)
Author:
markjaquith
Message:

Properly unset notoptions cache in add_option() so that get_option() and update_option() work on the same load. fixes #4429 for 2.2.x

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/wp-includes/functions.php

    r5713 r5789  
    355355    wp_protect_special_option($name);
    356356
    357     // Make sure the option doesn't already exist we can check the cache before we ask for a db query
     357    // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
    358358    $notoptions = wp_cache_get('notoptions', 'options');
    359     if ( is_array($notoptions) && isset($notoptions[$name]) ) {
    360         unset($notoptions[$name]);
    361         wp_cache_set('notoptions', $notoptions, 'options');
    362     } elseif ( false !== get_option($name) ) {
     359    if ( !is_array($notoptions) || !isset($notoptions[$name]) )
     360        if ( false !== get_option($name) )
    363361            return;
    364     }
    365362
    366363    $value = maybe_serialize($value);
     364    $autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
    367365
    368366    if ( 'yes' == $autoload ) {
     
    372370    } else {
    373371        wp_cache_set($name, $value, 'options');
     372    }
     373
     374    // This option exists now
     375    $notoptions = wp_cache_get('notoptions', 'options'); // yes, again... we need it to be fresh
     376    if ( is_array($notoptions) && isset($notoptions[$name]) ) {
     377        unset($notoptions[$name]);
     378        wp_cache_set('notoptions', $notoptions, 'options');
    374379    }
    375380
Note: See TracChangeset for help on using the changeset viewer.