Skip to content

Commit 50815ae

Browse files
committed
fix(Import): increase error again, when there was a gap in column headers
Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 044d62d commit 50815ae

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/Service/ImportService.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ private function getColumns(Row $firstRow, Row $secondRow): void {
457457
$index = 0;
458458
$countMatchingColumnsFromConfig = 0;
459459
$countCreatedColumnsFromConfig = 0;
460+
$lastCellWasEmpty = false;
461+
$hasGapInTitles = false;
460462
foreach ($cellIterator as $cell) {
461463
if ($cell && $cell->getValue() !== null && $cell->getValue() !== '') {
462464
$title = $cell->getValue();
@@ -480,12 +482,16 @@ private function getColumns(Row $firstRow, Row $secondRow): void {
480482

481483
// Convert data type to our data type
482484
$dataTypes[] = $this->parseColumnDataType($secondRowCellIterator->current());
485+
if ($lastCellWasEmpty) {
486+
$hasGapInTitles = true;
487+
}
488+
$lastCellWasEmpty = false;
483489
} else {
484490
$this->logger->debug('No cell given or cellValue is empty while loading columns for importing');
485491
if ($cell->getDataType() === 'null') {
486492
// LibreOffice generated XLSX doc may have more empty columns in the first row.
487-
// Continue without increasing error count.
488-
// Question: What about tables where a column does not have a heading?
493+
// Continue without increasing error count, but leave a marker to detect gaps in titles.
494+
$lastCellWasEmpty = true;
489495
continue;
490496
}
491497
$this->countErrors++;
@@ -494,6 +500,11 @@ private function getColumns(Row $firstRow, Row $secondRow): void {
494500
$index++;
495501
}
496502

503+
if ($hasGapInTitles) {
504+
$this->logger->info('Imported table is having a gap in column titles');
505+
$this->countErrors++;
506+
}
507+
497508
$this->rawColumnTitles = $titles;
498509
$this->rawColumnDataTypes = $dataTypes;
499510

0 commit comments

Comments
 (0)