Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Yaml] parse PHP constants in mapping keys#22878

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:3.3fromxabbuh:issue-22854
May 25, 2017

Conversation

@xabbuh
Copy link
Member

QA
Branch?3.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#22854
LicenseMIT
Doc PR

}
}elseif (
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:![^\s]++\s++)?[^\'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u',rtrim($this->currentLine),$values)
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?(?:![^\s]++\s++)?[^\'"\[\{!].*?) *\:(\s++(?P<value>.+))?$#u',rtrim($this->currentLine),$values)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

the!php/const tag is a bit special as it is separated with a colon from its value instead of a space which is used when parsing other tags

@chalasr
Copy link
Member

chalasr commentedMay 23, 2017
edited
Loading

@xabbuh with this the YAML will appear to be valid but, in addition to thePARSE_CONSTANTS flag, the DI YamlFIleLoader usesYaml::PARSE_KEYS_AS_STRING for parsing. Actually those aren't compatible for keys

@xabbuh
Copy link
MemberAuthor

Do you have a concrete example where this breaks a real application? This combination sounds like a real edge case to me.

@chalasr
Copy link
Member

chalasr commentedMay 23, 2017
edited
Loading

I mean that in 3.2, the following service:

foo:class:AppBundle\Fooarguments:        -!php/const:PHP_SAPI: bar

would have the following injected as first argument:

array('cli' =>'bar');

in 3.3, even with this, it would inject:

array(' !php/const:PHP_SAPI' =>'bar');

the DI file loader uses this edge combination since 3.3, so consts arent't resolved (the transition would be named!php/const:...)

@tgalopin
Copy link
Contributor

After solving the other problem described in the issue, I did encounter the problem explained by@chalasr:

                                                                                                                            [Symfony\Component\Workflow\Exception\InvalidArgumentException]                                                           The transition "!php/const:AppBundle\TonMacron\InvitationProcessor::TRANSITION_FILL_INFO" contains invalid characters.                                                                                                                            Exception trace: () at vendor/symfony/symfony/src/Symfony/Component/Workflow/Transition.php:34 Symfony\Component\Workflow\Transition->__construct() at n/a:n/a ReflectionClass->newInstanceArgs() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1078 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1195 Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1135 Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1135 Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1057 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:583 Symfony\Component\DependencyInjection\ContainerBuilder->get() at vendor/symfony/symfony/src/Symfony/Component/Workflow/DependencyInjection/ValidateWorkflowsPass.php:47 Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass->process() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:143 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:736 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:561 Symfony\Component\HttpKernel\Kernel->initializeContainer() at vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:120 Symfony\Component\HttpKernel\Kernel->boot() at vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:68 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:130 Symfony\Component\Console\Application->run() at bin/console:28

@xabbuh
Copy link
MemberAuthor

This is indeed an issue when thePARSE_CONSTANTandPARSE_KEYS_AS_STRINGS flags are used together. I have a failing test case locally and will look into a proper fix tonight.

tgalopin and surikman reacted with thumbs up emoji

@xabbuh
Copy link
MemberAuthor

constants should now be evaluated in mapping keys

@tgalopin Can you give this another try?

Status: Needs Review

Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

Works for me 👍

@tgalopin
Copy link
Contributor

Works for me too, thanks@xabbuh !

xabbuh reacted with hooray emoji

@xabbuh
Copy link
MemberAuthor

Thanks for the confirmation@chalasr and@tgalopin!

Copy link
Contributor

@GuilhemNGuilhemN left a comment

Choose a reason for hiding this comment

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

👍, I opened#22913 to get rid of this fix in 4.0.

Inline::$parsedLineNumber =$this->getRealCurrentLineNb();
$i =0;
$key = Inline::parseScalar($values['key'],0,null,$i, !(Yaml::PARSE_KEYS_AS_STRINGS &$flags));
$evaluateKey = !(Yaml::PARSE_KEYS_AS_STRINGS &$flags);
Copy link
Contributor

@GuilhemNGuilhemNMay 25, 2017
edited
Loading

Choose a reason for hiding this comment

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

I really don't get why we would ever want to use this flag, this is like saying "I don't want to respect the spec", don't you think we should just deprecate it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We need this to deprecate the previous behaviour. Otherwise we have no smooth upgrade path in 3.4.

Copy link
Contributor

Choose a reason for hiding this comment

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

#21774 introduced a small bc break anyway and this only allows people to go back to the old behavior by using this flag, right?

@nicolas-grekas
Copy link
Member

Thank you@xabbuh.

@nicolas-grekasnicolas-grekas merged commitae52fe6 intosymfony:3.3May 25, 2017
nicolas-grekas added a commit that referenced this pull requestMay 25, 2017
This PR was merged into the 3.3 branch.Discussion----------[Yaml] parse PHP constants in mapping keys| Q             | A| ------------- | ---| Branch?       | 3.3| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22854| License       | MIT| Doc PR        |Commits-------ae52fe6 [Yaml] parse PHP constants in mapping keys
@xabbuhxabbuh deleted the issue-22854 branchMay 25, 2017 13:40
@fabpotfabpot mentioned this pull requestMay 29, 2017
xabbuh added a commit that referenced this pull requestAug 4, 2017
This PR was squashed before being merged into the 3.4 branch (closes#22913).Discussion----------[Yaml] Deprecate tags using colon| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Using a colon in a tag doesn't look like yaml and causes trouble (see#22878), so I propose to just deprecate these tags in favor of more consistent tags.```yml- !php/const:PHP_INT_MAX- !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```would become```yml- !php/const PHP_INT_MAX- !php/object O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```Commits-------9815af3 [Yaml] Deprecate tags using colon
symfony-splitter pushed a commit to symfony/yaml that referenced this pull requestAug 4, 2017
This PR was squashed before being merged into the 3.4 branch (closes #22913).Discussion----------[Yaml] Deprecate tags using colon| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Using a colon in a tag doesn't look like yaml and causes trouble (seesymfony/symfony#22878), so I propose to just deprecate these tags in favor of more consistent tags.```yml- !php/const:PHP_INT_MAX- !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```would become```yml- !php/const PHP_INT_MAX- !php/object O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```Commits-------9815af3 [Yaml] Deprecate tags using colon
symfony-splitter pushed a commit to symfony/serializer that referenced this pull requestAug 4, 2017
This PR was squashed before being merged into the 3.4 branch (closes #22913).Discussion----------[Yaml] Deprecate tags using colon| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Using a colon in a tag doesn't look like yaml and causes trouble (seesymfony/symfony#22878), so I propose to just deprecate these tags in favor of more consistent tags.```yml- !php/const:PHP_INT_MAX- !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```would become```yml- !php/const PHP_INT_MAX- !php/object O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```Commits-------9815af3 [Yaml] Deprecate tags using colon
symfony-splitter pushed a commit to symfony/dependency-injection that referenced this pull requestAug 4, 2017
This PR was squashed before being merged into the 3.4 branch (closes #22913).Discussion----------[Yaml] Deprecate tags using colon| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Using a colon in a tag doesn't look like yaml and causes trouble (seesymfony/symfony#22878), so I propose to just deprecate these tags in favor of more consistent tags.```yml- !php/const:PHP_INT_MAX- !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```would become```yml- !php/const PHP_INT_MAX- !php/object O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```Commits-------9815af3 [Yaml] Deprecate tags using colon
symfony-splitter pushed a commit to symfony/validator that referenced this pull requestAug 4, 2017
This PR was squashed before being merged into the 3.4 branch (closes #22913).Discussion----------[Yaml] Deprecate tags using colon| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Using a colon in a tag doesn't look like yaml and causes trouble (seesymfony/symfony#22878), so I propose to just deprecate these tags in favor of more consistent tags.```yml- !php/const:PHP_INT_MAX- !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```would become```yml- !php/const PHP_INT_MAX- !php/object O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}```Commits-------9815af3 [Yaml] Deprecate tags using colon
fabpot added a commit that referenced this pull requestJun 25, 2022
This PR was merged into the 6.2 branch.Discussion----------[Yaml] Remove legacy parsing rule| Q             | A| ------------- | ---| Branch?       | 6.2| Bug fix?      | no| New feature?  | no| Deprecations? | no| Tickets       | -| License       | MIT| Doc PR        | -As far as I understood correctly, this part of the regexp has been introduced in#22878 to support a syntax that has been deprecated in#22913 and removed in 4.0.Commits-------5d7f9f2 [Yaml] Remove legacy parsing rule
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@GuilhemNGuilhemNGuilhemN left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

6 participants

@xabbuh@chalasr@tgalopin@nicolas-grekas@GuilhemN@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp