Skip to:
Content

BuddyPress.org

Changeset 7904


Ignore:
Timestamp:
02/17/2014 12:42:05 AM (8 years ago)
Author:
boonebgorges
Message:

Install default options at installation time and at upgrade to 2.0

When BuddyPress is installed, all basic config options should be saved to the
database, even when the setting is empty (0). This ensures that the options
will be pre-fetched by the first call to wp_load_alloptions() and stored in the
non-persistent cache, removing the necessity to make additional failed queries
to the wp_options table.

This changeset also includes logic to add missing default options to existing
default installations when upgrading to 2.0.

Fixes #5385

Location:
trunk
Files:
3 edited

Legend:

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

    r7893 r7904  
    8080
    8181        // Force the BuddyBar
    82         '_bp_force_buddybar'              => false
     82        '_bp_force_buddybar'              => false,
     83
     84        /** Legacy theme *********************************************/
     85
     86        // Whether to register the bp-default themes directory
     87        '_bp_retain_bp_default'           => false,
     88
     89        /** Widgets **************************************************/
     90        'widget_bp_core_login_widget'                => false,
     91        'widget_bp_core_members_widget'              => false,
     92        'widget_bp_core_whos_online_widget'          => false,
     93        'widget_bp_core_recently_active_widget'      => false,
     94        'widget_bp_groups_widget'                    => false,
     95        'widget_bp_messages_sitewide_notices_widget' => false,
    8396    );
    8497
     
    89102 * Add default options when BuddyPress is first activated.
    90103 *
    91  * Hooked to bp_activate, it is only called once when BuddyPress is activated.
    92  * This is non-destructive, so existing settings will not be overridden.
    93  *
    94  * Currently unused.
     104 * Only called once when BuddyPress is activated.
     105 * Non-destructive, so existing settings will not be overridden.
    95106 *
    96107 * @since BuddyPress (1.6.0)
     
    106117
    107118    // Add default options
    108     foreach ( $options as $key => $value )
    109         add_option( $key, $value );
     119    foreach ( $options as $key => $value ) {
     120        bp_add_option( $key, $value );
     121    }
    110122
    111123    // Allow previously activated plugins to append their own options.
  • trunk/bp-core/bp-core-update.php

    r7860 r7904  
    233233
    234234        // 2.0
    235         if ( $raw_db_version < 7859 ) {
     235        if ( $raw_db_version < 7892 ) {
    236236            bp_update_to_2_0();
    237237        }
     
    338338 * - Ensure that the activity tables are installed, for last_activity storage.
    339339 * - Migrate last_activity data from usermeta to activity table
     340 * - Add values for all BuddyPress options to the options table
    340341 */
    341342function bp_update_to_2_0() {
    342343    global $wpdb;
    343344
    344     // Install activity tables
     345    /** Install activity tables for 'last_activity' **********************/
    345346    bp_core_install_activity_streams();
    346347
    347348    $bp = buddypress();
    348349
    349     // Migrate data
     350    /** Migrate 'last_activity' data *************************************/
     351
    350352    // The "NOT IN" clause prevents duplicates
    351353    $sql = "INSERT INTO {$bp->members->table_name_last_activity} (`user_id`, `component`, `type`, `date_recorded` ) (
     
    363365
    364366    $wpdb->query( $sql );
     367
     368    /** Add BP options to the options table ******************************/
     369    bp_add_options();
    365370}
    366371
     
    405410    // Force refresh theme roots.
    406411    delete_site_transient( 'theme_roots' );
     412
     413    // Add options
     414    bp_add_options();
    407415
    408416    // Use as of (1.6)
  • trunk/bp-loader.php

    r7860 r7904  
    305305
    306306        $this->version    = '2.0-alpha-7752';
    307         $this->db_version = 7859;
     307        $this->db_version = 7892;
    308308
    309309        /** Loading ***************************************************/
Note: See TracChangeset for help on using the changeset viewer.