Skip to content

[Yaml] Regression in object support parser fix #17190

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

Closed
xabbuh opened this issue Dec 30, 2015 · 4 comments
Closed

[Yaml] Regression in object support parser fix #17190

xabbuh opened this issue Dec 30, 2015 · 4 comments

Comments

@xabbuh
Copy link
Member

xabbuh commented Dec 30, 2015

The fix for #17075 done in #17079 introduced a regression.

The following example:

use Symfony\Component\Yaml\Yaml;

print_r(Yaml::parse("foo: bar\nbaz: derp", false, false, true));

Is failing with the following exception:

PHP Fatal error:  Cannot use object of type stdClass as array in /path/to/vendor/symfony/symfony/src/Symfony/Component/Yaml/Parser.php on line 236
@xabbuh
Copy link
Member Author

xabbuh commented Dec 31, 2015

@IngwiePhoenix Can you please check if #17197 completely fixes the issue for you?

@IngwiePhoenix
Copy link

@xabbuh It seems to work. I had to learn how to pull in PRs, but I found ways to get there. I used this as a test:

<?php
require "vendor/autload.php";

use Symfony\Component\Yaml\Yaml;

print_r(Yaml::parse("foo: bar\nbaz: derp", false, false, true));

and it does print an stdClass object now. I will run this against a much bigger config file and tell you how that went.

@IngwiePhoenix
Copy link

Success. Works like a charm now. :)

@xabbuh
Copy link
Member Author

xabbuh commented Dec 31, 2015

@IngwiePhoenix Great, thanks for confirming. Next time I would just make the changes locally in your vendor directory (at least when the changeset is just so small). :)

ping @symfony/deciders

fabpot added a commit that referenced this issue Jan 4, 2016
…xabbuh)

This PR was merged into the 2.8 branch.

Discussion
----------

[Yaml] cast arrays to objects after parsing has finished

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17190
| License       | MIT
| Doc PR        |

Casting arrays to objects must happen after the complete YAML string has
been parsed to avoid errors when parsing subsequent lines.

Commits
-------

8251d67 cast arrays to objects after parsing has finished
@fabpot fabpot closed this as completed Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants