You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #20232, IniFileLoader no longer works correctly with ini files containing arrays:
Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\DependencyInjection\Loader\IniFileLoader::phpize() must be of the type string, array given, called in vendor/symfony/dependency-injection/Loader/IniFileLoader.php on line 44 and defined in vendor/symfony/dependency-injection/Loader/IniFileLoader.php on line 72
Call Stack:
1. {main}()
2. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->load()
3. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseImports() vendor/symfony/dependency-injection/Loader/XmlFileLoader.php:59
4. Symfony\Component\DependencyInjection\Loader\FileLoader->import() vendor/symfony/dependency-injection/Loader/XmlFileLoader.php:111
5. Symfony\Component\Config\Loader\FileLoader->import() vendor/symfony/dependency-injection/Loader/FileLoader.php:66
6. Symfony\Component\Config\Loader\FileLoader->doImport() vendor/symfony/config/Loader/FileLoader.php:104
7. Symfony\Component\DependencyInjection\Loader\IniFileLoader->load() vendor/symfony/config/Loader/FileLoader.php:165
8. Symfony\Component\DependencyInjection\Loader\IniFileLoader->phpize() vendor/symfony/dependency-injection/Loader/IniFileLoader.php:44
Previously, per the default behaviour of INI_SCANNER_NORMAL, the loader would always return values as string|string[]. There were some possible value substitutions, eg "true" became "1", however the deepest nested values were always a string.
The linked PR added intermediate parsing to convert these values to other scalar types, but incorrectly assumes the only possible input type is string. (Since version 4.4, this is by typehinting the private method's parameter, and before that by immediately calling \rtrim on the value.) This conversion isn't mentioned at all in the upgrading notes and there's still a caution in the docs suggesting other types aren't supported.
IniFileLoader::load should call \is_array on each parameter value, and when true call IniFileLoader::phpize for each array element instead of passing the entire array only once.
Additional Context
No response
The text was updated successfully, but these errors were encountered:
This PR was submitted for the 4.4 branch but it was merged into the 6.2 branch instead.
Discussion
----------
[DependencyInjection] Handle INI arrays
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#47357
| License | MIT
| Doc PR | N/A
Commits
-------
f90525c Handle INI arrays
Symfony version(s) affected
3.2.0-current
Description
Since #20232, IniFileLoader no longer works correctly with ini files containing arrays:
Previously, per the default behaviour of
INI_SCANNER_NORMAL
, the loader would always return values asstring|string[]
. There were some possible value substitutions, eg"true"
became"1"
, however the deepest nested values were always a string.The linked PR added intermediate parsing to convert these values to other scalar types, but incorrectly assumes the only possible input type is
string
. (Since version 4.4, this is by typehinting the private method's parameter, and before that by immediately calling\rtrim
on the value.) This conversion isn't mentioned at all in the upgrading notes and there's still a caution in the docs suggesting other types aren't supported.How to reproduce
Load a config file such as:
Expected values:
Actual behaviour:
TypeError
thrownPossible Solution
IniFileLoader::load
should call\is_array
on each parameter value, and when true callIniFileLoader::phpize
for each array element instead of passing the entire array only once.Additional Context
No response
The text was updated successfully, but these errors were encountered: