Make WordPress Core


Ignore:
Timestamp:
02/18/2015 07:13:43 PM (11 years ago)
Author:
boonebgorges
Message:

Respect 'default_option_' filters during early sanity checks in add_option() and update_option().

add_option() and update_option() both call get_option() to compare the
value passed to the function with any existing value for the given option name.
When a 'default_option_' filter is in place to change the default value of
an option, add_option() and update_option() ought to check against the
filtered value, rather than a hardcoded false, in order to determine whether
a prior value exists.

Props GregLone, tyxla.
Fixes #31047.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r31414 r31473  
    269269        return false;
    270270
    271     if ( false === $old_value )
     271    /** This filter is documented in wp-includes/option.php */
     272    if ( apply_filters( 'default_option_' . $option, false ) === $old_value )
    272273        return add_option( $option, $value );
    273274
     
    371372    $notoptions = wp_cache_get( 'notoptions', 'options' );
    372373    if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
    373         if ( false !== get_option( $option ) )
     374        /** This filter is documented in wp-includes/option.php */
     375        if ( apply_filters( 'default_option_' . $option, false ) !== get_option( $option ) )
    374376            return false;
    375377
Note: See TracChangeset for help on using the changeset viewer.