Skip to:
Content

BuddyPress.org

Changeset 10945


Ignore:
Timestamp:
07/18/2016 02:54:07 PM (5 years ago)
Author:
djpaul
Message:

Core: stash the unsubscribe email salt as a static var in bp_get_default_options().

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.

On WordPress older than 4.4, wp_rand's implementation was causing infinite loops because it 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. WordPress 4.4 re-implemented wp_rand and doesn't cause a loop.

File:
1 edited

Legend:

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

    r10941 r10945  
    1919 */
    2020function bp_get_default_options() {
     21    static $email_unsubscribe_salt = null;
     22
     23    // Only generate this once to prevent loops in wp_rand() on WP < 4.4.
     24    if ( $email_unsubscribe_salt === null ) {
     25        $email_unsubscribe_salt = base64_encode( wp_generate_password( 64, true, true ) );
     26    }
    2127
    2228    // Default options.
     
    7581
    7682        // Email unsubscribe salt.
    77         'bp-emails-unsubscribe-salt'           => base64_encode( wp_generate_password( 64, true, true ) ),
     83        'bp-emails-unsubscribe-salt'           => $email_unsubscribe_salt,
    7884
    7985        /* Groups ************************************************************/
Note: See TracChangeset for help on using the changeset viewer.