From 49349c47f8662542724e6af117f40efd0738af7f Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Wed, 4 Dec 2024 14:22:01 +0100 Subject: [PATCH 1/2] fix: an empty string is not a valid header name --- .../src/Command/FileReader/FileReaderImportCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php b/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php index 278f99a08..db2d6d82c 100644 --- a/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php +++ b/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $expressionLanguage = new ExpressionLanguage(); $rows = $this->fileReader->getData($file, false, $this->encoding); - $header = \array_map('trim', $rows[0] ?? []); + $header = \array_filter(\array_map('trim', $rows[0] ?? [])); $ouuids = []; if ($this->deleteMissingDocuments) { From 993aed963859a91af4e6e057b789f5fbe50070d4 Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Wed, 4 Dec 2024 14:22:59 +0100 Subject: [PATCH 2/2] fix: no need for empty data without header --- .../src/Command/FileReader/FileReaderImportCommand.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php b/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php index db2d6d82c..00092bf86 100644 --- a/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php +++ b/elasticms-cli/src/Command/FileReader/FileReaderImportCommand.php @@ -107,6 +107,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $row = []; $empty = true; foreach ($rowValues as $cellKey => $cell) { + if (null === ($header[$cellKey] ?? null) && null === $cell) { + continue; + } $row[$header[$cellKey] ?? $cellKey] = $cell; $empty = $empty && (null === $cell); }