Add flag for timeout checking
This commit is contained in:
parent
86c43459fc
commit
1d3c4ebb4d
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue