From 6f7e81416b097ebf99e6d72fd97729793f20e5f2 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 21 May 2010 14:15:59 +0000 Subject: [PATCH] Clone Objects in add_option()/update_option() to prevent storing PHP5 object references in memory cache. See [9740]. Fixes #13480 git-svn-id: https://develop.svn.wordpress.org/trunk@14777 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index cf1c0dbdfa..2c1b1f27d8 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -486,6 +486,9 @@ function update_option( $option, $newvalue ) { wp_protect_special_option( $option ); + if ( is_object($newvalue) ) + $newvalue = wp_clone($newvalue); + $newvalue = sanitize_option( $option, $newvalue ); $oldvalue = get_option( $option ); $newvalue = apply_filters( 'pre_update_option_' . $option, $newvalue, $oldvalue ); @@ -565,6 +568,10 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) return false; wp_protect_special_option( $option ); + + if ( is_object($value) ) + $value = wp_clone($value); + $value = sanitize_option( $option, $value ); // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query