Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/04/2012 03:28:57 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Converter:

  • Update verbiage of clean and restart checkboxes.
  • Audit usage of sync_table(), and make sure table is created correctly.
  • When deleting posts, check correct array items.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-converter.php

    r4053 r4055  
    126126                register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_convert_users',     'intval' );
    127127
     128                // Restart
     129                add_settings_field( '_bbp_converter_restart',       __( 'Start Over',        'bbpress' ), 'bbp_converter_setting_callback_restart', 'bbpress_converter', 'bbpress_converter_opt' );
     130                register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_restart',           'intval' );
     131
    128132                // Clean
    129                 add_settings_field( '_bbp_converter_clean',         __( 'Clean',            'bbpress' ), 'bbp_converter_setting_callback_clean', 'bbpress_converter', 'bbpress_converter_opt' );
     133                add_settings_field( '_bbp_converter_clean',         __( 'Purge Previous Import', 'bbpress' ), 'bbp_converter_setting_callback_clean', 'bbpress_converter', 'bbpress_converter_opt' );
    130134                register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_clean',             'intval' );
    131 
    132                 // Restart
    133                 add_settings_field( '_bbp_converter_restart',       __( 'Restart',           'bbpress' ), 'bbp_converter_setting_callback_restart', 'bbpress_converter', 'bbpress_converter_opt' );
    134                 register_setting  ( 'bbpress_converter_opt',        '_bbp_converter_restart',           'intval' );
    135135        }
    136136
    … …  
    337337                                                update_option( '_bbp_converter_step',  $step + 1 );
    338338                                                update_option( '_bbp_converter_start', 0         );
    339                                                 $this->sync_table();
     339                                                $this->sync_table( true );
    340340                                                if ( empty( $start ) ) {
    341341                                                        $this->converter_output( __( 'No data to clean', 'bbpress' ) );
    … …  
    510510
    511511                $table_name = $wpdb->prefix . 'bbp_converter_translator';
    512                 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
     512                if ( ! empty( $drop ) && $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name )
    513513                        $wpdb->query( "DROP TABLE {$table_name}" );
    514                 }
    515 
    516                 if ( empty( $drop ) ) {
    517                         require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
    518 
    519                         if ( !empty( $wpdb->charset ) ) {
    520                                 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    521                         }
    522 
    523                         if ( !empty( $wpdb->collate ) ) {
    524                                 $charset_collate .= " COLLATE $wpdb->collate";
    525                         }
    526 
    527                         /** Translator ****************************************************/
    528 
    529                         $sql = "CREATE TABLE {$table_name} (
    530                                                 meta_id mediumint(8) unsigned not null auto_increment,
    531                                                 value_type varchar(25) null,
    532                                                 value_id bigint(20) unsigned not null default '0',
    533                                                 meta_key varchar(25) null,
    534                                                 meta_value varchar(25) null,
    535                                         PRIMARY KEY  (meta_id),
    536                                                 KEY value_id (value_id),
    537                                                 KEY meta_join (meta_key, meta_value) ) {$charset_collate};";
    538 
    539                         dbDelta( $sql );
    540                 }
     514
     515                require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
     516
     517                if ( !empty( $wpdb->charset ) ) {
     518                        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     519                }
     520
     521                if ( !empty( $wpdb->collate ) ) {
     522                        $charset_collate .= " COLLATE $wpdb->collate";
     523                }
     524
     525                /** Translator ****************************************************/
     526
     527                $sql = "CREATE TABLE {$table_name} (
     528                                        meta_id mediumint(8) unsigned not null auto_increment,
     529                                        value_type varchar(25) null,
     530                                        value_id bigint(20) unsigned not null default '0',
     531                                        meta_key varchar(25) null,
     532                                        meta_value varchar(25) null,
     533                                PRIMARY KEY  (meta_id),
     534                                        KEY value_id (value_id),
     535                                        KEY meta_join (meta_key, meta_value) ) {$charset_collate};";
     536
     537                dbDelta( $sql );
    541538        }
    542539}
    … …  
    10401037                $posts = $this->wpdb->get_results( $query, ARRAY_A );
    10411038
    1042                 if ( !empty( $posts ) ) {
     1039                if ( isset( $posts[0] ) && ! empty( $posts[0]['value_id'] ) ) {
    10431040                        foreach ( (array) $posts as $value ) {
    10441041                                wp_delete_post( $value['value_id'], true );
Note: See TracChangeset for help on using the changeset viewer.