From c277384459d0675c4ee39ac0b696a6cec072009c Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 26 Feb 2010 18:51:37 +0000 Subject: [PATCH] Consistently pass unserialized values to hooks in update_site_option(). Change add_option() and add_site_option() to do the same. Any plugin using maybe_unserialize() would continue to work as the value would no longer need to be unserialized. fixes #10788 git-svn-id: http://svn.automattic.com/wordpress/trunk@13433 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index a2642d673a..6729d177f1 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -576,6 +576,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) if ( false !== get_option( $safe_option ) ) return; + $_value = $value; $value = maybe_serialize( $value ); $autoload = ( 'no' === $autoload ) ? 'no' : 'yes'; do_action( 'add_option', $option, $value ); @@ -599,8 +600,8 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $value, $autoload ) ); if ( $result ) { - do_action( "add_option_{$option}", $option, $value ); - do_action( 'added_option', $option, $value ); + do_action( "add_option_{$option}", $option, $_value ); + do_action( 'added_option', $option, $_value ); return true; } return false; @@ -3444,13 +3445,14 @@ function add_site_option( $option, $value ) { $value = sanitize_option( $option, $value ); wp_cache_set( $cache_key, $value, 'site-options' ); + $_value = $value; $value = maybe_serialize($value); $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) ); } - do_action( "add_site_option_{$option}", $option, $value ); - do_action( "add_site_option", $option, $value ); + do_action( "add_site_option_{$option}", $option, $_value ); + do_action( "add_site_option", $option, $_value ); return $result; } @@ -3532,8 +3534,10 @@ function update_site_option( $option, $value ) { $value = sanitize_option( $option, $value ); wp_cache_set( $cache_key, $value, 'site-options' ); + $_value = $value; $value = maybe_serialize( $value ); $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $value ), array( 'site_id' => $wpdb->siteid, 'meta_key' => $option ) ); + $value = $_value; } if ( $result ) {