Make WordPress Core

Ticket #26394: 26394.2.diff

File 26394.2.diff, 2.0 KB (added by MikeHansenMe, 10 years ago)
  • src/wp-includes/option.php

     
    224224 *
    225225 * @param string $option Option name. Expected to not be SQL-escaped.
    226226 * @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
     227 * @param string $autoload Autoload by default, while allowing it to be changed.
    227228 * @return bool False if value was not updated and true if value was updated.
    228229 */
    229 function update_option( $option, $value ) {
     230function update_option( $option, $value, $autoload = 'yes' ) {
    230231        global $wpdb;
    231232
    232         $option = trim($option);
    233         if ( empty($option) )
     233        $option = trim( $option );
     234        if ( empty( $option ) ) {
    234235                return false;
     236        }
    235237
    236238        wp_protect_special_option( $option );
    237239
    238         if ( is_object( $value ) )
     240        if ( is_object( $value ) ) {
    239241                $value = clone $value;
     242        }
    240243
    241244        $value = sanitize_option( $option, $value );
    242245        $old_value = get_option( $option );
     
    265268        $value = apply_filters( 'pre_update_option', $value, $option, $old_value );
    266269
    267270        // If the new and old values are the same, no need to update.
    268         if ( $value === $old_value )
     271        if ( $value === $old_value ) {
    269272                return false;
     273        }
    270274
    271275        /** This filter is documented in wp-includes/option.php */
    272         if ( apply_filters( 'default_option_' . $option, false ) === $old_value )
    273                 return add_option( $option, $value );
     276        if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) {
     277                return add_option( $option, $value, $autoload );
     278        }
    274279
    275280        $serialized_value = maybe_serialize( $value );
    276281
     
    286291        do_action( 'update_option', $option, $old_value, $value );
    287292
    288293        $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) );
    289         if ( ! $result )
     294        if ( ! $result ) {
    290295                return false;
     296        }
    291297
    292298        $notoptions = wp_cache_get( 'notoptions', 'options' );
    293299        if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {