diff --git a/includes/import/class-wc-product-csv-importer.php b/includes/import/class-wc-product-csv-importer.php index 560fa5e8e9e..6dcfa3babf8 100644 --- a/includes/import/class-wc-product-csv-importer.php +++ b/includes/import/class-wc-product-csv-importer.php @@ -31,13 +31,14 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { */ public function __construct( $file, $params = array() ) { $default_args = array( - 'start_pos' => 0, // File pointer start. - 'end_pos' => -1, // File pointer end. - 'lines' => -1, // Max lines to read. - 'mapping' => array(), // Column mapping. csv_heading => schema_heading. - 'parse' => false, // Whether to sanitize and format data. - 'update_existing' => false, // Whether to update existing items. - 'delimiter' => ',', // CSV delimiter. + 'start_pos' => 0, // File pointer start. + 'end_pos' => -1, // File pointer end. + 'lines' => -1, // Max lines to read. + 'mapping' => array(), // Column mapping. csv_heading => schema_heading. + 'parse' => false, // Whether to sanitize and format data. + 'update_existing' => false, // Whether to update existing items. + 'delimiter' => ',', // CSV delimiter. + 'prevent_timeouts' => true, // Check memory and time usage and abort if reaching limit. ); $this->params = wp_parse_args( $params, $default_args ); @@ -711,7 +712,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer { $index ++; - if ( $this->time_exceeded() || $this->memory_exceeded() ) { + if ( $this->params['prevent_timeouts'] && ( $this->time_exceeded() || $this->memory_exceeded() ) ) { $this->file_position = $this->file_positions[ $index ]; break; } diff --git a/tests/unit-tests/importer/product.php b/tests/unit-tests/importer/product.php index 83377b6c764..0270ce97884 100644 --- a/tests/unit-tests/importer/product.php +++ b/tests/unit-tests/importer/product.php @@ -84,8 +84,9 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case { */ public function test_import() { $args = array( - 'mapping' => $this->get_csv_mapped_items(), - 'parse' => true, + 'mapping' => $this->get_csv_mapped_items(), + 'parse' => true, + 'prevent_timeouts' => false, ); $importer = new WC_Product_CSV_Importer( $this->csv_file, $args );