Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/19/2018 07:00:55 AM (7 years ago)
Author:
johnjamesjacoby
Message:

Converter: remove WP_SETUP_CONFIG constant setting from converter process.

This introduces a helper database class to avoid directly connecting to the external database. Instead, we'll attempt to control that connection, and provide feedback to the user in the event a connection cannot be made. The WP_SETUP_CONFIG was causing calls to the options API to fail, resulting in broken calculations and invalid offsets.

This commit includes some general load order clean-up, which also fixes a regression causing fatal errors when attempting to upgrade converted user passwords from the old platform. It also fixes the condition where boundaries being converted would display beyond their maximums.

Fixes #3191.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/classes/class-bbp-converter.php

    r6681 r6785  
    216216
    217217        // Maybe prepend the step
    218         $progress = ! empty( $this->step )
    219             ? sprintf( '<span class="step">%s.</span><span class="output">%s</span><span class="mini-step">%s</span>', $this->step, $output, $this->step_percentage . '%' )
    220             : $output;
     218        if ( ! empty( $this->step ) ) {
     219
     220            // Include percentage
     221            if ( ! empty( $this->rows_in_step ) ) {
     222                $progress = sprintf( '<span class="step">%s.</span><span class="output">%s</span><span class="mini-step">%s</span>', $this->step, $output, $this->step_percentage . '%' );
     223
     224            // Don't include percentage
     225            } else {
     226                $progress = sprintf( '<span class="step">%s.</span><span class="output">%s</span>', $this->step, $output );
     227            }
     228
     229        // Raw text
     230        } else {
     231            $progress = $output;
     232        }
    221233
    222234        // Output
     
    428440     */
    429441    private function bump_start() {
     442
     443        // Set rows in step from option
     444        $this->rows_in_step = get_option( '_bbp_converter_rows_in_step', 0 );
     445
     446        // Get rows to start from
    430447        $start = (int) ( $this->start + $this->rows );
    431448
     449        // Enforce maximum if exists
     450        if ( $this->rows_in_step > 0 ) {
     451
     452            // Start cannot be larger than total rows
     453            if ( $start > $this->rows_in_step ) {
     454                $start = $this->rows_in_step;
     455            }
     456
     457            // Max can't be greater than total rows
     458            if ( $this->max > $this->rows_in_step ) {
     459                $this->max = $this->rows_in_step;
     460            }
     461        }
     462
     463        // Update the start option
    432464        update_option( '_bbp_converter_start', $start );
    433465    }
     
    467499            } else {
    468500                $this->bump_start();
    469                 $this->converter_response( sprintf( esc_html__( 'Deleting previously converted data (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step) );
     501                $this->converter_response( sprintf( esc_html__( 'Deleting previously converted data (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max ) );
    470502            }
    471503
     
    493525            } else {
    494526                $this->bump_start();
    495                 $this->converter_response( sprintf(  esc_html__( 'Converting users (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
     527                $this->converter_response( sprintf( esc_html__( 'Converting users (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
    496528            }
    497529        } else {
     
    516548            } else {
    517549                $this->bump_start();
    518                 $this->converter_response( sprintf( esc_html__( 'Delete default WordPress user passwords (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) );
     550                $this->converter_response( sprintf( esc_html__( 'Delete default WordPress user passwords (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max ) );
    519551            }
    520552        } else {
Note: See TracChangeset for help on using the changeset viewer.