- Timestamp:
- 02/19/2018 07:00:55 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/classes/class-bbp-converter-base.php
r6780 r6785 139 139 // Maybe add port to server 140 140 if ( ! empty( $db_port ) && ! empty( $db_host ) && ! strstr( $db_host, ':' ) ) { 141 $db_host = $db_host . ':' . $db_port;141 $db_host = "{$db_host}:{$db_port}"; 142 142 } 143 143 … … 147 147 $this->wpdb = bbp_db(); 148 148 149 // Control WPDB db_connect() bailing150 define( 'WP_SETUP_CONFIG', true );151 152 149 // Setup old forum Database 153 $this->opdb = new wpdb( $db_user, $db_pass, $db_name, $db_host );150 $this->opdb = new BBP_Converter_DB( $db_user, $db_pass, $db_name, $db_host ); 154 151 155 152 // Connection failed … … 499 496 /** New user **************************************/ 500 497 501 case 'user' :498 case 'user' : 502 499 if ( username_exists( $insert_post['user_login'] ) ) { 503 $insert_post['user_login'] = 'imported_' . $insert_post['user_login'];500 $insert_post['user_login'] = "imported_{$insert_post['user_login']}"; 504 501 } 505 502 506 503 if ( email_exists( $insert_post['user_email'] ) ) { 507 $insert_post['user_email'] = 'imported_' . $insert_post['user_email'];504 $insert_post['user_email'] = "imported_{$insert_post['user_email']}"; 508 505 } 509 506 … … 523 520 524 521 if ( '_id' == substr( $key, -3 ) && ( true === $this->sync_table ) ) { 525 $this->wpdb->insert( $this->sync_table_name, array( 'value_type' => 'user', 'value_id' => $post_id, 'meta_key' => $key, 'meta_value' => $value ) ); 522 $this->wpdb->insert( $this->sync_table_name, array( 523 'value_type' => 'user', 524 'value_id' => $post_id, 525 'meta_key' => $key, 526 'meta_value' => $value 527 ) ); 526 528 } 527 529 } … … 531 533 /** New Topic-Tag *********************************/ 532 534 533 case 'tags' :535 case 'tags' : 534 536 $post_id = wp_set_object_terms( $insert_postmeta['objectid'], $insert_postmeta['name'], 'topic-tag', true ); 535 537 $term = get_term_by( 'name', $insert_postmeta['name'], 'topic-tag'); … … 544 546 /** Forum Subscriptions ***************************/ 545 547 546 case 'forum_subscriptions' :548 case 'forum_subscriptions' : 547 549 $user_id = $insert_post['user_id']; 548 550 $items = wp_list_pluck( $insert_postmeta, '_bbp_forum_subscriptions' ); … … 565 567 /** Subscriptions *********************************/ 566 568 567 case 'topic_subscriptions' :569 case 'topic_subscriptions' : 568 570 $user_id = $insert_post['user_id']; 569 571 $items = wp_list_pluck( $insert_postmeta, '_bbp_subscriptions' ); … … 586 588 /** Favorites *************************************/ 587 589 588 case 'favorites' :590 case 'favorites' : 589 591 $user_id = $insert_post['user_id']; 590 592 $items = wp_list_pluck( $insert_postmeta, '_bbp_favorites' ); … … 607 609 /** Forum, Topic, Reply ***************************/ 608 610 609 default :611 default : 610 612 $post_id = wp_insert_post( $insert_post, true ); 611 613 … … 634 636 */ 635 637 if ( '_id' === substr( $key, -3 ) && ( true === $this->sync_table ) ) { 636 $this->wpdb->insert( $this->sync_table_name, array( 'value_type' => 'post', 'value_id' => $post_id, 'meta_key' => $key, 'meta_value' => $value ) ); 638 $this->wpdb->insert( $this->sync_table_name, array( 639 'value_type' => 'post', 640 'value_id' => $post_id, 641 'meta_key' => $key, 642 'meta_value' => $value 643 ) ); 637 644 } 638 645 … … 665 672 $has_update = false; 666 673 $query = ! empty( $this->sync_table ) 667 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_forum_parent_id' )674 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_forum_parent_id' ) 668 675 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_forum_parent_id' ); 669 676 … … 685 692 $has_update = false; 686 693 $query = ! empty( $this->sync_table ) 687 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'sticky' )694 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'sticky' ) 688 695 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'sticky' ); 689 696 … … 704 711 $has_update = false; 705 712 $query = ! empty( $this->sync_table ) 706 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'super-sticky' )713 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'super-sticky' ) 707 714 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'super-sticky' ); 708 715 … … 724 731 $has_update = false; 725 732 $query = ! empty( $this->sync_table ) 726 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_closed_status_id', 'closed' )733 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_closed_status_id', 'closed' ) 727 734 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_closed_status_id', 'closed' ); 728 735 … … 743 750 $has_update = false; 744 751 $query = ! empty( $this->sync_table ) 745 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_reply_to_id' )752 ? $this->wpdb->prepare( "SELECT value_id, meta_value FROM {$this->sync_table_name} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_reply_to_id' ) 746 753 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_reply_to_id' ); 747 754 … … 766 773 if ( ! empty( $this->sync_table ) ) { 767 774 $query = $this->wpdb->prepare( "SELECT sync_table1.value_id AS topic_id, sync_table1.meta_value AS topic_is_anonymous, sync_table2.meta_value AS topic_author 768 769 770 771 772 773 775 FROM {$this->sync_table_name} AS sync_table1 776 INNER JOIN {$this->sync_table_name} AS sync_table2 777 ON ( sync_table1.value_id = sync_table2.value_id ) 778 WHERE sync_table1.meta_value = %s 779 AND sync_table2.meta_key = %s 780 LIMIT {$start}, {$this->max_rows}", 'true', '_bbp_old_topic_author_name_id' ); 774 781 } else { 775 782 $query = $this->wpdb->prepare( "SELECT wp_postmeta1.post_id AS topic_id, wp_postmeta1.meta_value AS topic_is_anonymous, wp_postmeta2.meta_value AS topic_author 776 777 778 779 780 781 783 FROM {$this->wpdb->postmeta} AS wp_postmeta1 784 INNER JOIN {$this->wpdb->postmeta} AS wp_postmeta2 785 ON ( wp_postmeta1.post_id = wp_postmeta2.post_id ) 786 WHERE wp_postmeta1.meta_value = %s 787 AND wp_postmeta2.meta_key = %s 788 LIMIT {$start}, {$this->max_rows}", 'true', '_bbp_old_topic_author_name_id' ); 782 789 } 783 790 … … 805 812 if ( ! empty( $this->sync_table ) ) { 806 813 $query = $this->wpdb->prepare( "SELECT sync_table1.value_id AS reply_id, sync_table1.meta_value AS reply_is_anonymous, sync_table2.meta_value AS reply_author 807 808 809 810 811 812 814 FROM {$this->sync_table_name} AS sync_table1 815 INNER JOIN {$this->sync_table_name} AS sync_table2 816 ON ( sync_table1.value_id = sync_table2.value_id ) 817 WHERE sync_table1.meta_value = %s 818 AND sync_table2.meta_key = %s 819 LIMIT {$start}, {$this->max_rows}", 'true', '_bbp_old_reply_author_name_id' ); 813 820 } else { 814 821 $query = $this->wpdb->prepare( "SELECT wp_postmeta1.post_id AS reply_id, wp_postmeta1.meta_value AS reply_is_anonymous, wp_postmeta2.meta_value AS reply_author 815 816 817 818 819 820 822 FROM {$this->wpdb->postmeta} AS wp_postmeta1 823 INNER JOIN {$this->wpdb->postmeta} AS wp_postmeta2 824 ON ( wp_postmeta1.post_id = wp_postmeta2.post_id ) 825 WHERE wp_postmeta1.meta_value = %s 826 AND wp_postmeta2.meta_key = %s 827 LIMIT {$start}, {$this->max_rows}", 'true', '_bbp_old_reply_author_name_id' ); 821 828 } 822 829 … … 928 935 * @param string The table name to grab fields from 929 936 */ 930 private function get_fields( $tablename ) { 931 $rval = array(); 932 $field_array = $this->get_results( 'DESCRIBE ' . $tablename, ARRAY_A ); 933 937 private function get_fields( $tablename = '' ) { 938 $retval = array(); 939 $field_array = $this->get_results( "DESCRIBE {$tablename}", ARRAY_A ); 940 941 // Bail if no fields 942 if ( empty( $field_array ) ) { 943 return $retval; 944 } 945 946 // Add fields to array 934 947 foreach ( $field_array as $field ) { 935 $rval[] = $field['Field']; 936 } 937 948 if ( ! empty( $field['Field'] ) ) { 949 $retval[] = $field['Field']; 950 } 951 } 952 953 // Add social fields for users table 938 954 if ( $tablename === $this->wpdb->users ) { 939 $r val[] = 'role';940 $r val[] = 'yim';941 $r val[] = 'aim';942 $r val[] = 'jabber';943 } 944 945 return $r val;955 $retval[] = 'role'; 956 $retval[] = 'yim'; 957 $retval[] = 'aim'; 958 $retval[] = 'jabber'; 959 } 960 961 return $retval; 946 962 } 947 963
Note: See TracChangeset
for help on using the changeset viewer.