8000 [Yaml] Fix regression when trying to parse multiline by antograssiot · Pull Request #26387 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Yaml] Fix regression when trying to parse multiline #26387

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
Apr 3, 2018

Conversation

antograssiot
Copy link
Contributor
@antograssiot antograssiot commented Mar 3, 2018
Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #22967
License MIT
Doc PR

I think this is the lower impacted branch, it fixes a regression added in the last releases campain some days ago.

As discused on Slack @xabbuh

@antograssiot
Copy link
Contributor Author

Seems it might be fixing #22967 and avoiding regression again as it was working in the previous releases

@@ -421,7 +421,7 @@ private function doParse($value, $flags)
}

// try to parse the value as a multi-line string as a last resort
if (0 === $this->currentLineNb) {
if (0 === $this->currentLineNb && 1 < $this->totalNumberOfLines && !$this->isNextLineIndented()) {
Copy link
Member

Choose a reason for hiding this comment

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

foo:
  bar
    baz

Will such a YAML string still work?

Copy link
Member

Choose a reason for hiding this comment

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

the result should be ['foo' => 'bar baz']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed it doesn't. I'll add more tests and try to find another fix

@antograssiot
Copy link
Contributor Author

Status: Needs Work

@antograssiot antograssiot force-pushed the yml-regression branch 2 times, most recently from f47ced3 to 36474f8 Compare March 5, 2018 23:57
@antograssiot
Copy link
Contributor Author

Status: Needs Review

@xabbuh I've tried another approach and only account for indentation inconsistency at offset 0. I added more test based on your comments and my findings

@antograssiot
Copy link
Contributor Author

@xabbuh is this good enough or is there missing test or a better/shorter solution ?

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Mar 12, 2018
@@ -427,6 +427,10 @@ private function doParse($value, $flags)
$value = '';

foreach ($this->lines as $line) {
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
if (0 === $this->offset && !$deprecatedUsage && rtrim($line) !== trim($line)) {
Copy link
Member

Choose a reason for hiding this comment

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

What about using 0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0] here instead to avoid calling (r)trim()?

Copy link
Member

Choose a reason for hiding this comment

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

And is the check for $deprecatedUsage really needed? Which test would fail without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xabbuh thank you very much for your review and your feedback. Your version would work of course, I'll update.
The $deprecated check is only needed in 3.4 because of this test....
https://github.com/symfony/symfony/blob/3.4/src/Symfony/Component/Yaml/Tests/ParserTest.php#L1787-L1800 that checks that the deprecation message is thrown.
In 4.0, the exception is expected (https://github.com/symfony/symfony/blob/4.0/src/Symfony/Component/Yaml/Tests/ParserTest.php#L1689-L1702)

I'm not familiar with how you idealy deals with this...

@antograssiot
Copy link
Contributor Author

updated and rebased @xabbuh

Copy link
Member
@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

The changes look good to me.

@antograssiot
Copy link
Contributor Author

failing test are not related

@nicolas-grekas
Copy link
Member

Does this PR fix #22967? If yes, could you please update the PR description accordingly?

@antograssiot
Copy link
Contributor Author

It does @nicolas-grekas, PR description edited as requested

@fabpot
Copy link
Member
fabpot commented Apr 3, 2018

Thank you @antograssiot.

@fabpot fabpot merged commit e787ecf into symfony:3.4 Apr 3, 2018
fabpot added a commit that referenced this pull request Apr 3, 2018
…grassiot)

This PR was squashed before being merged into the 3.4 branch (closes #26387).

Discussion
----------

[Yaml] Fix regression when trying to parse multiline

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

I think this is the lower impacted branch, it fixes a regression added in the last releases campain some days ago.

As discused on Slack @xabbuh

Commits
-------

e787ecf [Yaml] Fix regression when trying to parse multiline
This was referenced Apr 3, 2018
@antograssiot antograssiot deleted the yml-regression branch April 8, 2018 16:48
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.

6 participants
0