Exemplo n.º 1
0
/**
 * Output the BuddyPress database version.
 *
 * @since BuddyPress (1.6.0)
 *
 * @uses bp_get_db_version_raw() To get the current database BuddyPress version.
 */
function bp_db_version_raw()
{
    echo bp_get_db_version_raw();
}
/**
 * BuddyPress's version updater looks at what the current database version is,
 * and runs whatever other code is needed.
 *
 * This is most-often used when the data schema changes, but should also be used
 * to correct issues with BuddyPress metadata silently on software update.
 *
 * @since BuddyPress (1.7)
 */
function bp_version_updater()
{
    // Get the raw database version
    $raw_db_version = (int) bp_get_db_version_raw();
    $default_components = apply_filters('bp_new_install_default_components', array('activity' => 1, 'members' => 1, 'xprofile' => 1));
    require_once BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php';
    // Install BP schema and activate only Activity and XProfile
    if (bp_is_install()) {
        // Apply schema and set Activity and XProfile components as active
        bp_core_install($default_components);
        bp_update_option('bp-active-components', $default_components);
        bp_core_add_page_mappings($default_components, 'delete');
        // Upgrades
    } else {
        // Run the schema install to update tables
        bp_core_install();
        // 1.5
        if ($raw_db_version < 1801) {
            bp_update_to_1_5();
            bp_core_add_page_mappings($default_components, 'delete');
        }
        // 1.6
        if ($raw_db_version < 6067) {
            bp_update_to_1_6();
        }
    }
    /** All done! *************************************************************/
    // Bump the version
    bp_version_bump();
}
Exemplo n.º 3
0
/**
 * Initialize an update or installation of BuddyPress.
 *
 * BuddyPress's version updater looks at what the current database version is,
 * and runs whatever other code is needed - either the "update" or "install"
 * code.
 *
 * This is most often used when the data schema changes, but should also be used
 * to correct issues with BuddyPress metadata silently on software update.
 *
 * @since BuddyPress (1.7.0)
 */
function bp_version_updater()
{
    // Get the raw database version
    $raw_db_version = (int) bp_get_db_version_raw();
    $default_components = apply_filters('bp_new_install_default_components', array('activity' => 1, 'members' => 1, 'settings' => 1, 'xprofile' => 1, 'notifications' => 1));
    require_once buddypress()->plugin_dir . '/bp-core/admin/bp-core-schema.php';
    // Install BP schema and activate only Activity and XProfile
    if (bp_is_install()) {
        // Apply schema and set Activity and XProfile components as active
        bp_core_install($default_components);
        bp_update_option('bp-active-components', $default_components);
        bp_core_add_page_mappings($default_components, 'delete');
        // Upgrades
    } else {
        // Run the schema install to update tables
        bp_core_install();
        // 1.5
        if ($raw_db_version < 1801) {
            bp_update_to_1_5();
            bp_core_add_page_mappings($default_components, 'delete');
        }
        // 1.6
        if ($raw_db_version < 6067) {
            bp_update_to_1_6();
        }
        // 1.9
        if ($raw_db_version < 7553) {
            bp_update_to_1_9();
        }
        // 1.9.2
        if ($raw_db_version < 7731) {
            bp_update_to_1_9_2();
        }
        // 2.0
        if ($raw_db_version < 7892) {
            bp_update_to_2_0();
        }
        // 2.0.1
        if ($raw_db_version < 8311) {
            bp_update_to_2_0_1();
        }
    }
    /** All done! *************************************************************/
    // Bump the version
    bp_version_bump();
}
Exemplo n.º 4
0
/**
 * Perform database operations that must take place before the general schema upgrades.
 *
 * `dbDelta()` cannot handle certain operations - like changing indexes - so we do it here instead.
 *
 * @since 2.3.0
 */
function bp_pre_schema_upgrade()
{
    global $wpdb;
    $raw_db_version = (int) bp_get_db_version_raw();
    $bp_prefix = bp_core_get_table_prefix();
    // 2.3.0: Change index lengths to account for utf8mb4.
    if ($raw_db_version < 9695) {
        // table_name => columns.
        $tables = array($bp_prefix . 'bp_activity_meta' => array('meta_key'), $bp_prefix . 'bp_groups_groupmeta' => array('meta_key'), $bp_prefix . 'bp_messages_meta' => array('meta_key'), $bp_prefix . 'bp_notifications_meta' => array('meta_key'), $bp_prefix . 'bp_user_blogs_blogmeta' => array('meta_key'), $bp_prefix . 'bp_xprofile_meta' => array('meta_key'));
        foreach ($tables as $table_name => $indexes) {
            foreach ($indexes as $index) {
                if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", bp_esc_like($table_name)))) {
                    $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index}");
                }
            }
        }
    }
}
Exemplo n.º 5
0
 /** Save Step Methods *****************************************************/
 function step_db_update_save()
 {
     if (isset($_POST['submit'])) {
         check_admin_referer('bpwizard_db_update');
         // Run the schema install to update tables
         bp_core_install();
         // Update to 1.5
         if (bp_get_db_version_raw() < 1801) {
             $this->update_1_5();
         }
         // Update to 1.6
         if (bp_get_db_version_raw() < bp_get_db_version()) {
             $this->update_1_6();
         }
         return true;
     }
     return false;
 }