fix: validate headers of the compound metadata on impot csv
This commit is contained in:
parent
7e43b825ec
commit
1e74183e1f
|
@ -197,7 +197,12 @@ class CSV extends Importer {
|
||||||
? explode( $this->get_option('multivalued_delimiter'), $valueToInsert)
|
? explode( $this->get_option('multivalued_delimiter'), $valueToInsert)
|
||||||
: [$valueToInsert];
|
: [$valueToInsert];
|
||||||
|
|
||||||
|
if(!is_array($header)) {
|
||||||
|
$this->add_error_log('the compound metadata specification is invalid');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$key = key($header);
|
$key = key($header);
|
||||||
|
|
||||||
$returnValue = [];
|
$returnValue = [];
|
||||||
foreach($valueToInsert as $index => $metadatumValue) {
|
foreach($valueToInsert as $index => $metadatumValue) {
|
||||||
$childrenHeaders = str_getcsv($compoundHeaders[$key], $this->get_option('delimiter'), $this->get_option('enclosure'));
|
$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'));
|
str_getcsv($metadatumValue, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||||
|
|
||||||
if ( sizeof($childrenHeaders) != sizeof($childrenValue) ) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
|
|
Loading…
Reference in New Issue