mvc: catch empty data in CSV import

Catch empty lines.  A single "," will generate
an empty string instead of NULL so we are good
here.  It's safe to assume we have at least one
property in the line, otherwise the data is
useless to us anyway.

From the fgetcsv() manual:

A blank line in a CSV file will be returned as an array
comprising a single null field, and will not be treated
as an error.

See: https://www.php.net/manual/en/function.fgetcsv.php
This commit is contained in:
Franco Fichtner 2026-02-11 13:23:15 +01:00
parent 774a51d626
commit ed748aef15

View file

@ -674,7 +674,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase
while (($line = fgetcsv($stream, null, $separator)) !== false) {
if (empty($heading)) {
$heading = $line;
} else {
} elseif (count($line) >= 1 && !is_null($line[0])) {
$record = [];
foreach ($line as $idx => $content) {
if (isset($heading[$idx])) {