-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony YAML parser doesn't handle complex YAML format #20579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We cannot replace the Symfony component by the PHP extension, as it would force people to install an uncommon PHP extension to use Symfony, which is a no-go (even the much more common And as the Symfony parser is turning mappings to associative PHP arrays, it cannot support using arrays as keys for instance. This is why support for complex mappings was never implemented until now. |
What should be possible is to detect the case of complex mappings and provide a more meaningful exception messages. |
@BourotBenjamin possibly it should be possible to make a wrapper around the pecl extension which implements the interface needed by symfony. Then you could replace the yaml class yourself. |
As my problem was created by an external service ( OneSky ) that exports complex yml event when you don't need complex keys, and I used a bundle to import and export files ( OpenClassrooms/OneSkyBundle ), I thought the best idea was to handle the problem in this bundle. So I made a pull request to asks to install pecl_yaml with this bundle and made it laod the file by the pelc_yaml loader but export it with the SF2's yaml dumper. |
@xabbuh do you think these improved exception messages would be easy to implement? Will you be able to do that for 3.3 (the feature freeze is in 32 days)? Thanks! |
@javiereguiluz I am not sure, but I try to find a way to make that change. |
see #22058 |
I think we need to deprecate the current behaviour first (see #22059). |
This PR was merged into the 3.3-dev branch. Discussion ---------- [Yaml] deprecate "? " starting unquoted strings | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #20579 | License | MIT | Doc PR | Commits ------- 731a74e [Yaml] deprecate "? " starting unquoted strings
The deprecated behaviour will be removed in #22770. |
@BourotBenjamin I found the parsing Yaml file using PHP instead of c-extension badly inefficient. |
As described here :
http://yaml.org/spec/1.2/spec.html#id2760395
But, when I try to load a valid YAML file using complex mappig, I got an error :
My file content :
As PECL YAML extension ( https://pecl.php.net/package/yaml ) exists, works fine and seems more complete than symfony's one, wouldn't be more simple to replace Symfony's YAML component by php extension ?
What do you think ?
The text was updated successfully, but these errors were encountered: