Commit 1fd5a2c
committed
bug #63064 [Translation] Fix handling of empty lines in CsvFileLoader (fnogatz)
This PR was submitted for the 8.1 branch but it was squashed and merged into the 6.4 branch instead.
Discussion
----------
[Translation] Fix handling of empty lines in CsvFileLoader
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | (none)
| License | MIT
In its current version, the `CsvFileLoader` of [symfony/translation](https://github.com/symfony/translation) does not support empty lines within the CSV file due to a missing `SplFileObject::DROP_NEW_LINE` flag (cf. [PHP documentation](https://www.php.net/manual/en/class.splfileobject.php#splfileobject.constants)). Without this change, this would result in a warning like this:
```
CsvFileLoader.php:44
str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated
```
This PR changes the test file `resources.csv` to contain an empty line, and adds the missing flag in `CsvFileLoader::loadResource()`. I'm not sure whether this should be handled as a bugfix or new feature. Adding the flag doesn't break backward compatibility.
Commits
-------
61a1414 [Translation] Fix handling of empty lines in CsvFileLoader2 files changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | | - | |
| 6 | + | |
0 commit comments