-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hello, I was trying to create a CSV file where one of the fields lists multiple URLs. For peoples' viewing pleasure, I thought I will separate those URLs using "\n". Kind of like this:
"Source page node id", "Broken Links in this page"
42, "https://example.net/foo
https://example.net/bar
https://example.net/bar"
162, "https://example.net/qux"
But the output from drush insert-command-here --format=csv kept producing a truncated version like the following:
"Source page node id", "Broken Links in this page"
42, "https://example.net/foo
162, "https://example.net/qux"
Turned out the CSV formatter is keeping the first line of each CSV row only:
| $csv = fgets($buffer); |
Fix is easy (patch pasted below). I am happy to raise a pull request, but I am wondering if the current behaviour is intentional or not. Please advice.
--- /path/to/drupal/vendor/consolidation/output-formatters/src/Formatters/CsvFormatter.php 2020-10-11 05:15:32.000000000 +0100
+++ CsvFormatter.php 2021-03-12 20:03:39.327122512 +0000
@@ -123,9 +123,11 @@
} else {
fputcsv($buffer, $data, $delimiter, $enclosure);
}
+ $buffer_length = ftell($buffer);
rewind($buffer);
- $csv = fgets($buffer);
+ $csv = fread($buffer, $buffer_length);
fclose($buffer);
+
return $csv;
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels