From 3e87a2b88d8040b6873887e9faa73d78024458eb Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Sat, 7 Jul 2007 04:06:29 +0000 Subject: [PATCH] Properly unset notoptions cache in add_option() so that get_option() and update_option() work on the same load. fixes #4429 for trunk git-svn-id: https://develop.svn.wordpress.org/trunk@5788 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 2740e127db..7052916950 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -314,14 +314,11 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') { wp_protect_special_option($name); - // Make sure the option doesn't already exist we can check the cache before we ask for a db query + // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query $notoptions = wp_cache_get('notoptions', 'options'); - if ( is_array($notoptions) && isset($notoptions[$name]) ) { - unset($notoptions[$name]); - wp_cache_set('notoptions', $notoptions, 'options'); - } elseif ( false !== get_option($name) ) { + if ( !is_array($notoptions) || !isset($notoptions[$name]) ) + if ( false !== get_option($name) ) return; - } $value = maybe_serialize($value); $autoload = ( 'no' === $autoload ) ? 'no' : 'yes'; @@ -334,6 +331,13 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') { wp_cache_set($name, $value, 'options'); } + // This option exists now + $notoptions = wp_cache_get('notoptions', 'options'); // yes, again... we need it to be fresh + if ( is_array($notoptions) && isset($notoptions[$name]) ) { + unset($notoptions[$name]); + wp_cache_set('notoptions', $notoptions, 'options'); + } + $name = $wpdb->escape($name); $value = $wpdb->escape($value); $description = $wpdb->escape($description);