From 4d6ecc49435301577dfb59cc4e10024f8f388e15 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Sat, 16 Jul 2005 21:13:14 +0000 Subject: [PATCH] Check it if matches before serializing, because get_option de-serializes. Hat tip: Donncha. git-svn-id: https://develop.svn.wordpress.org/trunk@2715 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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;