mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Options fixes from donncha. fixes #1859
git-svn-id: http://svn.automattic.com/wordpress/trunk@3023 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3a088cfaf1
commit
8e154dc493
@ -58,6 +58,7 @@ case 'update':
|
||||
$new_val = 'closed';
|
||||
if ($new_val !== $old_val) {
|
||||
$result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
|
||||
wp_cache_set($option->option_name, $new_val, 'options');
|
||||
$any_changed++;
|
||||
}
|
||||
}
|
||||
|
@ -267,8 +267,11 @@ function get_settings($setting) {
|
||||
$value = wp_cache_get($setting, 'options');
|
||||
|
||||
if ( false === $value ) {
|
||||
$value = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
|
||||
wp_cache_add($setting, $value, 'options');
|
||||
$value = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
|
||||
if( is_object( $value ) ) {
|
||||
$value = $value->option_value;
|
||||
wp_cache_set($setting, $value, 'options');
|
||||
}
|
||||
}
|
||||
|
||||
// If home is not set use siteurl.
|
||||
@ -343,7 +346,7 @@ function update_option($option_name, $newvalue) {
|
||||
|
||||
// If it's not there add it
|
||||
if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$option_name'") )
|
||||
add_option($option_name);
|
||||
add_option($option_name, $newvalue);
|
||||
|
||||
wp_cache_set($option_name, $newvalue, 'options');
|
||||
|
||||
@ -365,14 +368,14 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') {
|
||||
global $wpdb;
|
||||
|
||||
// Make sure the option doesn't already exist
|
||||
if ( false !== get_option($name, 'options') )
|
||||
if ( false !== get_option($name) )
|
||||
return;
|
||||
|
||||
$original = $value;
|
||||
if ( is_array($value) || is_object($value) )
|
||||
$value = serialize($value);
|
||||
|
||||
wp_cache_add($name, $value, 'options');
|
||||
wp_cache_set($name, $value, 'options');
|
||||
|
||||
$name = $wpdb->escape($name);
|
||||
$value = $wpdb->escape($value);
|
||||
|
Loading…
Reference in New Issue
Block a user