Use ON DUPLICATE KEY UPDATE when inserting options to avoid duplicate entry errors. fixes #11437
git-svn-id: https://develop.svn.wordpress.org/trunk@12403 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
86c09f699b
commit
1e123f43a7
|
@ -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