8000 [Yaml] Stop replacing NULLs when merging by ostrolucky · Pull Request #21756 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Yaml] Stop replacing NULLs when merging #21756

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

Merged
merged 1 commit into from
Feb 26, 2017
Merged

Conversation

ostrolucky
Copy link
Contributor
@ostrolucky ostrolucky commented Feb 25, 2017
Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

This introduces slight change of behaviour. Whereas previous code is overwriting already processed NULL values, this code is not. I think this is more expected behaviour, though?

@GuilhemN
Copy link
Contributor

What about using array_replace instead ? It would be clearer imo.

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Feb 25, 2017
@nicolas-grekas
Copy link
Member

There is a difference between the removed and the new code : any pre-existing null value was overridden previously, but isn't anymore. I don't if that's a bug for or a regression. It would be great to have a test case ensure the correct behavior is tested.

@ostrolucky
Copy link
Contributor Author
ostrolucky commented Feb 25, 2017

@GuilhemN Yeah it would be clearer since this operator isn't widely used, but array_replace is also slower. I try to make my changes without performance impact. I think we can instead solve this by adding // comment to indicate what we are doing if you wish. What do you guys think?

@nicolas-grekas Yep I'm aware of that. I'll let you guys decide what is correct behaviour, then I will modify my patch appropriately, even if it's only adding the test case. IMO duplicate keys are not supposed to be overwriting any previously set values. In 3.2 there was even deprecated ability to specify duplicate keys. I can even modify this to make this trigger deprecation instead, however I don't know what message is appropriate, since I'm not familiar what does this block of parser do.

@nicolas-grekas
Copy link
Member

The correct behavior is dictated by the yaml spec. @xabbuh or @GuilhemN any hint on that topic?

@GuilhemN
Copy link
Contributor

@nicolas-grekas I didn't check but I don't see any good reason justifiing a different behavior for null so I think it's a mistake here.

@GuilhemN
Copy link
Contributor

Nothing is said about null so I understand that it should behave the same as any other value.

@nicolas-grekas
Copy link
Member

@gadelat can you add a test case in this direction please?

@ostrolucky ostrolucky changed the title [Yaml] Utilize PHP array union operator in a Parser [Yaml] Stop replacing NULLs when merging Feb 25, 2017
@xabbuh
Copy link
Member
xabbuh commented Feb 26, 2017

👍 This will solve the initial overlook that didn't take into account that isset() returns false for null values.

Status: Reviewed

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@xabbuh
Copy link
Member
xabbuh commented Feb 26, 2017

Thank you @gadelat.

@xabbuh xabbuh merged commit d967440 into symfony:2.7 Feb 26, 2017
xabbuh added a commit that referenced this pull request Feb 26, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[Yaml] Stop replacing NULLs when merging

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

This introduces slight change of behaviour. Whereas previous code is overwriting already processed NULL values, this code is not. I think this is more expected behaviour, though?

Commits
-------

d967440 [Yaml] Stop replacing NULLs when merging
This was referenced Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0