Make WordPress Core

Changeset 5788


Ignore:
Timestamp:
07/07/2007 04:06:29 AM (19 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 trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r5709 r5788  
    315315        wp_protect_special_option($name);
    316316
    317         // Make sure the option doesn't already exist we can check the cache before we ask for a db query
     317        // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
    318318        $notoptions = wp_cache_get('notoptions', 'options');
    319         if ( is_array($notoptions) && isset($notoptions[$name]) ) {
    320                 unset($notoptions[$name]);
    321                 wp_cache_set('notoptions', $notoptions, 'options');
    322         } elseif ( false !== get_option($name) ) {
     319        if ( !is_array($notoptions) || !isset($notoptions[$name]) )
     320                if ( false !== get_option($name) )
    323321                        return;
    324         }
    325322
    326323        $value = maybe_serialize($value);
     
    333330        } else {
    334331                wp_cache_set($name, $value, 'options');
     332        }
     333
     334        // This option exists now
     335        $notoptions = wp_cache_get('notoptions', 'options'); // yes, again... we need it to be fresh
     336        if ( is_array($notoptions) && isset($notoptions[$name]) ) {
     337                unset($notoptions[$name]);
     338                wp_cache_set('notoptions', $notoptions, 'options');
    335339        }
    336340
Note: See TracChangeset for help on using the changeset viewer.