Skip to:
Content

BuddyPress.org

Changeset 11093


Ignore:
Timestamp:
09/13/2016 05:00:17 PM (5 years ago)
Author:
djpaul
Message:

BuddyPress, Emails: set value of bp-emails-unsubscribe-salt option for new installs.

The initial value was set in bp_get_default_options() and worked because that function adds missing options to the database when it's ran.
For version updates, the new option was already being explictly added elsewhere.

However if a plugin is active and loads before the plugins_loaded hook, and calls add_option() or update_option() (or multisite equivalents), a fatal error is caused by the bp_core_clear_root_options_cache()` function.
This is because wp_generate_password() in used in bp_get_default_options() to set the bp-emails-unsubscribe-salt option, which is only available via wp-includes/pluggable.php. That file is only loaded by WordPress after plugins are loaded.

This change sets the default value in bp_get_default_options(), and then explicitly updates the value to the unsubscribe halts in the existing email installation function.

Fixes #7227
See #7254

Props r-a-y, DJPaul

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

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

    r10941 r11093  
    519519    }
    520520
     521    bp_update_option( 'bp-emails-unsubscribe-salt', base64_encode( wp_generate_password( 64, true, true ) ) );
     522
    521523    /**
    522524     * Fires after BuddyPress adds the posts for its emails.
  • trunk/src/bp-core/bp-core-options.php

    r10949 r11093  
    1414 * Get the default site options and their values.
    1515 *
     16 * Default values should not be set by calls to `get_option()` or `get_site_option()` due to
     17 * these causing load order problems with `bp_core_clear_root_options_cache()`; see #BP7227.
     18 *
    1619 * @since 1.6.0
    1720 *
     
    7578
    7679        // Email unsubscribe salt.
    77         'bp-emails-unsubscribe-salt'           => base64_encode( wp_generate_password( 64, true, true ) ),
     80        'bp-emails-unsubscribe-salt'           => '',
    7881
    7982        /* Groups ************************************************************/
Note: See TracChangeset for help on using the changeset viewer.