diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 7afec8c3e3..e8e8ba3b24 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -327,21 +327,22 @@ function get_alloptions() { function update_option($option_name, $newvalue) { global $wpdb, $cache_settings; - if ( is_array($newvalue) || is_object($newvalue) ) - $newvalue = serialize($newvalue); $newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim - // If the new and old values are the same, no need to update. - if ($newvalue == get_option($option_name)) { - return true; - } + // If the new and old values are the same, no need to update. + if ( $newvalue == get_option($option_name) ) + return true; + + if ( is_array($newvalue) || is_object($newvalue) ) + $newvalue = serialize($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); $newvalue = $wpdb->escape($newvalue); + $option_name = $wpdb->escape( $option_name ); $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'"); $cache_settings = get_alloptions(); // Re cache settings return true;