Пример #1
0
function bp_update_db_stuff()
{
    $bp_prefix = bp_core_get_table_prefix();
    // Rename the old user activity cached table if needed.
    if ($nxtdb->get_var("SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'")) {
        $nxtdb->query("RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}");
    }
    // Rename fields from pre BP 1.2
    if ($nxtdb->get_var("SHOW TABLES LIKE '%{$bp->activity->table_name}%'")) {
        if ($nxtdb->get_var("SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'")) {
            $nxtdb->query("ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL");
        }
        if ($nxtdb->get_var("SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'")) {
            $nxtdb->query("ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL");
        }
    }
    // On first installation - record all existing blogs in the system.
    if (!(int) $bp->site_options['bp-blogs-first-install']) {
        bp_blogs_record_existing_blogs();
        bp_update_option('bp-blogs-first-install', 1);
    }
    if (is_multisite()) {
        bp_core_add_illegal_names();
    }
    // Update and remove the message threads table if it exists
    if ($nxtdb->get_var("SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'")) {
        $update = BP_Messages_Thread::update_tables();
        if ($update) {
            $nxtdb->query("DROP TABLE {$bp_prefix}bp_messages_threads");
        }
    }
}