From 11e3c1733b8c8f91d4ee86411a35185bdb23fc13 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 15 Dec 2009 16:00:23 +0000 Subject: [PATCH] Use ON DUPLICATE KEY UPDATE when inserting options to avoid duplicate entry errors. fixes #11437 git-svn-id: http://svn.automattic.com/wordpress/trunk@12403 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index b17b409e0e..19ac29c949 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -600,7 +600,7 @@ function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) { wp_cache_set( 'notoptions', $notoptions, 'options' ); } - $wpdb->insert($wpdb->options, array('option_name' => $name, 'option_value' => $value, 'autoload' => $autoload) ); + $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`)", $name, $value, $autoload ) ); do_action( "add_option_{$name}", $name, $value ); do_action( 'added_option', $name, $value );