From b2150816f8a4d1e620d97a3efae5e349205511bf Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 11 May 2010 17:35:07 +0000 Subject: [PATCH] Don't update meta data when the new value matches the old value. fixes #13350 git-svn-id: http://svn.automattic.com/wordpress/trunk@14564 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/meta.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 582e3307e..67ea8611e 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -109,6 +109,15 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) ) return add_metadata($meta_type, $object_id, $meta_key, $meta_value); + // Compare existing value to new value if no prev value given and the key exists only once. + if ( empty($prev_value) ) { + $old_value = get_metadata($meta_type, $object_id, $meta_key); + if ( count($old_value) == 1 ) { + if ( $old_value[0] == $meta_value ) + return false; + } + } + $_meta_value = $meta_value; $meta_value = maybe_serialize( stripslashes_deep($meta_value) );