Skip to:
Content

BuddyPress.org

Ticket #1884: sql-fix.diff

File sql-fix.diff, 2.2 KB (added by rvenable, 14 years ago)
  • bp-activity.php

     
    2323
    2424        /* Rename fields from pre BP 1.2 */
    2525        if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {
    26                 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );
    27                 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );
     26                if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )
     27                        $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );
     28                if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) )
     29                        $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );
    2830        }
    2931
    3032        /**
  • bp-xprofile.php

     
    7676        ) {$charset_collate};";
    7777
    7878        if ( '' == get_site_option( 'bp-xprofile-db-version' ) ) {
    79                 $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );";
     79                if ( !$wpdb->get_var("SELECT id FROM {$bp->profile->table_name_groups} WHERE id = 1") )
     80                        $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );";
    8081
    81                 $sql[] = "INSERT INTO {$bp->profile->table_name_fields} (
    82                                         id, group_id, parent_id, type, name, is_required, can_delete
    83                                   ) VALUES (
    84                                         1, 1, 0, 'textbox', '" . get_site_option( 'bp-xprofile-fullname-field-name' ) . "', 1, 0
    85                                   );";
     82                if ( !$wpdb->get_var("SELECT id FROM {$bp->profile->table_name_fields} WHERE id = 1") )
     83                        $sql[] = "INSERT INTO {$bp->profile->table_name_fields} (
     84                                                id, group_id, parent_id, type, name, is_required, can_delete
     85                                          ) VALUES (
     86                                                1, 1, 0, 'textbox', '" . get_site_option( 'bp-xprofile-fullname-field-name' ) . "', 1, 0
     87                                          );";
    8688        }
    8789
    8890        require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );