MDL-36113 - lib: Importing csv entries with empty lines in the middle doesn't throw errors.

This commit is contained in:
Adrian Greeve 2012-11-05 11:31:31 +08:00
parent 6109f2112c
commit 415a6ffcc8

View File

@ -105,7 +105,15 @@ class csv_import_reader {
// str_getcsv doesn't iterate through the csv data properly. It has
// problems with line returns.
while ($fgetdata = fgetcsv($fp, 0, $csv_delimiter, $enclosure)) {
$columns[] = $fgetdata;
// Check to see if we have an empty line.
if (count($fgetdata) == 1) {
if ($fgetdata[0] !== null) {
// The element has data. Add it to the array.
$columns[] = $fgetdata;
}
} else {
$columns[] = $fgetdata;
}
}
$col_count = 0;