mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
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: http://svn.automattic.com/wordpress/trunk@5788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b721942f26
commit
9b0c0d56db
@ -314,14 +314,11 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') {
|
|||||||
|
|
||||||
wp_protect_special_option($name);
|
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');
|
$notoptions = wp_cache_get('notoptions', 'options');
|
||||||
if ( is_array($notoptions) && isset($notoptions[$name]) ) {
|
if ( !is_array($notoptions) || !isset($notoptions[$name]) )
|
||||||
unset($notoptions[$name]);
|
if ( false !== get_option($name) )
|
||||||
wp_cache_set('notoptions', $notoptions, 'options');
|
|
||||||
} elseif ( false !== get_option($name) ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
$value = maybe_serialize($value);
|
$value = maybe_serialize($value);
|
||||||
$autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
|
$autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
|
||||||
@ -334,6 +331,13 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') {
|
|||||||
wp_cache_set($name, $value, 'options');
|
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);
|
$name = $wpdb->escape($name);
|
||||||
$value = $wpdb->escape($value);
|
$value = $wpdb->escape($value);
|
||||||
$description = $wpdb->escape($description);
|
$description = $wpdb->escape($description);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user