add_site_option should not update existing options, should return a boolean and should only run actions on success. fixes #18422

git-svn-id: http://svn.automattic.com/wordpress/trunk@18587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
duck_ 2011-08-23 20:24:35 +00:00
parent fdedc8a500
commit 56f6f97125
1 changed files with 12 additions and 9 deletions

View File

@ -569,11 +569,10 @@ function update_option( $option, $newvalue ) {
* it will be serialized before it is inserted into the database. Remember,
* resources can not be serialized or added as an option.
*
* You can create options without values and then add values later. Does not
* check whether the option has already been added, but does check that you
* You can create options without values and then update the values later.
* Existing options will not be updated and checks are performed to ensure that you
* aren't adding a protected WordPress option. Care should be taken to not name
* options the same as the ones which are protected and to not add options
* that were already added.
* options the same as the ones which are protected.
*
* @package WordPress
* @subpackage Option
@ -3775,6 +3774,8 @@ function get_site_option( $option, $default = false, $use_cache = true ) {
/**
* Add a new site option.
*
* Existing options will not be updated. Note that prior to 3.3 this wasn't the case.
*
* @see add_option()
* @package WordPress
* @subpackage Option
@ -3799,7 +3800,7 @@ function add_site_option( $option, $value ) {
$cache_key = "{$wpdb->siteid}:$option";
if ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
return update_site_option( $option, $value );
return false;
$value = sanitize_option( $option, $value );
wp_cache_set( $cache_key, $value, 'site-options' );
@ -3810,10 +3811,12 @@ function add_site_option( $option, $value ) {
$value = $_value;
}
if ( $result ) {
do_action( "add_site_option_{$option}", $option, $value );
do_action( "add_site_option", $option, $value );
return $result;
return true;
}
return false;
}
/**