Skip to content

Commit

Permalink
Fix infinite loop caused by wrongly incremented step
Browse files Browse the repository at this point in the history
  • Loading branch information
ppetrov committed Feb 16, 2018
1 parent dd56a31 commit 5a39b21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Import_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,16 @@ public function start() {
$imported_rows = [];

$csv = $this->import_process->get_csv();
$start_row = ( intval( $this->step ) === 1 && $this->import_process->first_row_header ) ? 1 : ( $this->step - 1 ) * $this->settings['rows_per_request'];
$total_rows = $csv->count();
$start_row = ( intval( $this->step ) === 1 && $this->import_process->first_row_header ) ? 1 : ( $this->step - 1 ) * $this->settings['rows_per_request'] + 1;
$csv->skip_to_row( $start_row );

$row_number = 0;
foreach ($csv as $row) {
if ( $start_row > $total_rows ) {
break;
}

try {
$import_status = $this->import_process->import_row($row);
} catch (\Exception $e) {
Expand Down

0 comments on commit 5a39b21

Please sign in to comment.