WordPress.org

Make WordPress Core

Changeset 18587


Ignore:
Timestamp:
08/23/11 20:24:35 (3 years ago)
Author:
duck_
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r18567 r18587  
    570570 * resources can not be serialized or added as an option. 
    571571 * 
    572  * You can create options without values and then add values later. Does not 
    573  * check whether the option has already been added, but does check that you 
     572 * You can create options without values and then update the values later. 
     573 * Existing options will not be updated and checks are performed to ensure that you 
    574574 * aren't adding a protected WordPress option. Care should be taken to not name 
    575  * options the same as the ones which are protected and to not add options 
    576  * that were already added. 
     575 * options the same as the ones which are protected. 
    577576 * 
    578577 * @package WordPress 
     
    37763775 * Add a new site option. 
    37773776 * 
     3777 * Existing options will not be updated. Note that prior to 3.3 this wasn't the case. 
     3778 * 
    37783779 * @see add_option() 
    37793780 * @package WordPress 
     
    38003801 
    38013802        if ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) ) 
    3802             return update_site_option( $option, $value ); 
     3803            return false; 
    38033804 
    38043805        $value = sanitize_option( $option, $value ); 
     
    38113812    } 
    38123813 
    3813     do_action( "add_site_option_{$option}", $option, $value ); 
    3814     do_action( "add_site_option", $option, $value ); 
    3815  
    3816     return $result; 
     3814    if ( $result ) { 
     3815        do_action( "add_site_option_{$option}", $option, $value ); 
     3816        do_action( "add_site_option", $option, $value ); 
     3817        return true; 
     3818    } 
     3819    return false; 
    38173820} 
    38183821 
Note: See TracChangeset for help on using the changeset viewer.