Skip to content

Commit

Permalink
fix(Import): increase error again, when there was a gap in column hea…
Browse files Browse the repository at this point in the history
…ders

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Nov 26, 2024
1 parent 044d62d commit 50815ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/Service/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ private function getColumns(Row $firstRow, Row $secondRow): void {
$index = 0;
$countMatchingColumnsFromConfig = 0;
$countCreatedColumnsFromConfig = 0;
$lastCellWasEmpty = false;
$hasGapInTitles = false;
foreach ($cellIterator as $cell) {
if ($cell && $cell->getValue() !== null && $cell->getValue() !== '') {
$title = $cell->getValue();
Expand All @@ -480,12 +482,16 @@ private function getColumns(Row $firstRow, Row $secondRow): void {

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

if ($hasGapInTitles) {
$this->logger->info('Imported table is having a gap in column titles');
$this->countErrors++;
}

$this->rawColumnTitles = $titles;
$this->rawColumnDataTypes = $dataTypes;

Expand Down

0 comments on commit 50815ae

Please sign in to comment.