Skip to:
Content

bbPress.org

Changeset 5425


Ignore:
Timestamp:
07/07/2014 01:51:38 PM (10 years ago)
Author:
netweb
Message:

Re-factor importing closed topics to import the closed status and update the closed topic post and post meta status using bbp_close_topic(). See #2577

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/converter.php

    r5424 r5425  
    468468                break;
    469469
    470             // STEP 9. Convert tags.
     470            // STEP 9. Closed Topics.
    471471            case 9 :
     472                if ( $converter->convert_topic_closed_topics( $start ) ) {
     473                    update_option( '_bbp_converter_step',  $step + 1 );
     474                    update_option( '_bbp_converter_start', 0         );
     475                    if ( empty( $start ) ) {
     476                        $this->converter_output( __( 'No closed topics to close', 'bbpress' ) );
     477                    }
     478                } else {
     479                    update_option( '_bbp_converter_start', $max + 1 );
     480                    $this->converter_output( sprintf( __( 'Calculating closed topics (%1$s - %2$s)', 'bbpress' ), $min, $max ) );
     481                }
     482
     483                break;
     484
     485            // STEP 10. Convert tags.
     486            case 10 :
    472487                if ( $converter->convert_tags( $start ) ) {
    473488                    update_option( '_bbp_converter_step',  $step + 1 );
     
    483498                break;
    484499
    485             // STEP 10. Convert replies.
    486             case 10 :
     500            // STEP 11. Convert replies.
     501            case 11 :
    487502                if ( $converter->convert_replies( $start ) ) {
    488503                    update_option( '_bbp_converter_step',  $step + 1 );
     
    498513                break;
    499514
    500             // STEP 11. Convert reply_to parents.
    501             case 11 :
     515            // STEP 12. Convert reply_to parents.
     516            case 12 :
    502517                if ( $converter->convert_reply_to_parents( $start ) ) {
    503518                    update_option( '_bbp_converter_step',  $step + 1 );
     
    11291144
    11301145    /**
     1146     * This method converts old closed topics to bbPress closed topics.
     1147     *
     1148     * @since bbPress (r5425)
     1149     *
     1150     * @uses bbp_close_topic() to close topics properly
     1151     *
     1152     */
     1153    public function convert_topic_closed_topics( $start ) {
     1154
     1155        $has_update = false;
     1156
     1157        if ( !empty( $this->sync_table ) ) {
     1158            $query = 'SELECT value_id, meta_value FROM ' . $this->sync_table_name           . ' WHERE meta_key = "_bbp_old_closed_status_id" AND meta_value = "closed" LIMIT ' . $start . ', ' . $this->max_rows;
     1159        } else {
     1160            $query = 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . ' WHERE meta_key = "_bbp_old_closed_status_id" AND meta_value = "closed" LIMIT ' . $start . ', ' . $this->max_rows;
     1161        }
     1162
     1163        update_option( '_bbp_converter_query', $query );
     1164
     1165        $closed_topic = $this->wpdb->get_results( $query );
     1166
     1167        foreach ( (array) $closed_topic as $row ) {
     1168            bbp_close_topic( $row->value_id );
     1169            $has_update = true;
     1170        }
     1171
     1172        return ! $has_update;
     1173    }
     1174
     1175    /**
    11311176     * This method converts old reply_to post id to new bbPress reply_to post id.
    11321177     *
Note: See TracChangeset for help on using the changeset viewer.