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
This commit is contained in:
parent
acf271551d
commit
11e3c1733b
|
@ -600,7 +600,7 @@ function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
|
||||||
wp_cache_set( 'notoptions', $notoptions, 'options' );
|
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( "add_option_{$name}", $name, $value );
|
||||||
do_action( 'added_option', $name, $value );
|
do_action( 'added_option', $name, $value );
|
||||||
|
|
Loading…
Reference in New Issue