From 1e74183e1f4cee98643d3737a492cc58860a81e6 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Wed, 8 May 2024 16:19:48 -0300 Subject: [PATCH] fix: validate headers of the compound metadata on impot csv --- src/classes/importer/class-tainacan-csv.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/classes/importer/class-tainacan-csv.php b/src/classes/importer/class-tainacan-csv.php index d31f72503..ee8d0d30d 100644 --- a/src/classes/importer/class-tainacan-csv.php +++ b/src/classes/importer/class-tainacan-csv.php @@ -197,7 +197,12 @@ class CSV extends Importer { ? explode( $this->get_option('multivalued_delimiter'), $valueToInsert) : [$valueToInsert]; + if(!is_array($header)) { + $this->add_error_log('the compound metadata specification is invalid'); + continue; + } $key = key($header); + $returnValue = []; foreach($valueToInsert as $index => $metadatumValue) { $childrenHeaders = str_getcsv($compoundHeaders[$key], $this->get_option('delimiter'), $this->get_option('enclosure')); @@ -206,7 +211,7 @@ class CSV extends Importer { str_getcsv($metadatumValue, $this->get_option('delimiter'), $this->get_option('enclosure')); if ( sizeof($childrenHeaders) != sizeof($childrenValue) ) { - $this->add_error_log('Mismatch count headers childrens and row columns. file value:' . $metadatumValue); + $this->add_error_log('Mismatch count headers childrens and row columns in compound metadata. file value:' . $metadatumValue); return false; } $tmp = [];