Add flag for timeout checking

This commit is contained in:
claudiulodro 2017-06-14 11:35:22 -07:00
parent 86c43459fc
commit 1d3c4ebb4d
2 changed files with 12 additions and 10 deletions

View File

@ -38,6 +38,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
'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;
}

View File

@ -86,6 +86,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
$args = array(
'mapping' => $this->get_csv_mapped_items(),
'parse' => true,
'prevent_timeouts' => false,
);
$importer = new WC_Product_CSV_Importer( $this->csv_file, $args );