Skip to:
Content

BuddyPress.org

Changeset 10950


Ignore:
Timestamp:
07/20/2016 06:20:32 PM (3 years ago)
Author:
djpaul
Message:

Core: fix infinite loop in bp_core_clear_root_options_cache

In r10941, an email unsubscribe feature was introduced. This added a new site option that stores the verification salt. For new installations, we added the variable to bp_add_options, and for upgrades, in a new function. We generate the value by using a randomly-generated string, which uses wp_rand internally.

On WordPress older than 4.4, wp_rand's implementation was causing infinite loops in bp_core_clear_root_options_cache because that adds its own site option, and BuddyPress has some cache clearing logic in bp_core_clear_root_options_cache which is called whenever options are added or updated, which in turns re-calls bp_get_default_options.

We now un-hook/re-hook bp_core_clear_root_options_cache inside that function to prevent loops.

WordPress 4.4+ re-implemented wp_rand and doesn't cause a loop.

See #6932

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-cache.php

    r10497 r10950  
    116116 */
    117117function bp_core_clear_root_options_cache( $option ) {
     118    foreach ( array( 'add_option', 'add_site_option', 'update_option', 'update_site_option' ) as $action ) {
     119        remove_action( $action, 'bp_core_clear_root_options_cache' );
     120    }
     121
     122    // Surrounding code prevents infinite loops on WP < 4.4.
    118123    $keys = array_keys( bp_get_default_options() );
     124
     125    foreach ( array( 'add_option', 'add_site_option', 'update_option', 'update_site_option' ) as $action ) {
     126        add_action( $action, 'bp_core_clear_root_options_cache' );
     127    }
     128
    119129    $keys = array_merge( $keys, array(
    120130        'registration',
Note: See TracChangeset for help on using the changeset viewer.