8000 [Config] Fixes the valid placeholder types for variable node · Pull Request #26895 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Config] Fixes the valid placeholder types for variable node #26895

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 16, 2018
Merged

[Config] Fixes the valid placeholder types for variable node #26895

merged 1 commit into from Apr 16, 2018

Conversation

ghost
Copy link
@ghost ghost commented Apr 11, 2018
Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? we will see...
Fixed tickets #26894
License MIT

This is a proposition, still in discussion.

@xabbuh
Copy link
Member
xabbuh commented Apr 12, 2018

@ro0NL Can you have a look here?

@ro0NL
Copy link
Contributor
ro0NL commented Apr 12, 2018

Hm, @romain-pierre you are using an env-var for a variable node type right?

I think we can say it allows all types (including array AFAIK). So maybe the better fix is

-if (array_diff($knownTypes, $validTypes))
+if ($validTypes && array_diff($knownTypes, $validTypes))

Could you try that?

@ghost
Copy link
Author
ghost commented Apr 12, 2018

Absolutely, the use case is the SncRedis configuration (see) that allows env placeholder. The resulting error is:

Invalid type for path "snc_redis.clients.default.dsns.0". Expected one of "", but got "string".

For your suggestion, why not, it's an other approach, if you consider that non scalar types are also allowed. So, we could consider that in the case of VariableNode use, this is the responsibility of the user to check the type, and not the one of the Config componement? If your are agree with that, I can change my PR by this way.

@ro0NL
Copy link
Contributor
ro0NL commented Apr 12, 2018

if you consider that non scalar types are also allowed

That's already possible no? I can pass any value to a variable node type...

@ghost
Copy link
Author
ghost commented Apr 12, 2018

Yeah you probably right, but I never see this case for now.

The last question I have: there is no confusion/bug risk to disable the check when no type are allowed? It's hard to admit that if [string] is in [] is true.

@ro0NL
Copy link
Contributor
ro0NL commented Apr 12, 2018

there is no confusion/bug risk to disable the check when no type are allowed?

We should add test for variable nodes yes, see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php#L227

@ro0NL
Copy link
Contributor
ro0NL commented Apr 12, 2018

there is no confusion/bug risk to disable the check when no type are allowed?

The feature is new in 4.1, custom node types are not really affected yet. So yes, safe move IMHO.

Empty array means all types are valid (accepting no types is nonsense :)) and is actually a BC fix i guess.

@ghost
Copy link
Author
ghost commented Apr 12, 2018

You convinced me (to avoid BC break). But if accepting no types is nonsense it should throw an exception IMHO, in a perfect world.

I will update this PR with your proposition.

Copy link
Contributor
@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

extra test would be nice :)

@ghost
Copy link
Author
ghost commented Apr 13, 2018

If you are ready to wait a little bit, I'm in to write some tests about this fix (in an other PR?), it could be a good training for me.

@ro0NL
Copy link
Contributor
ro0NL commented Apr 13, 2018

Same PR i'd say. Let me know if you need help :)

In general add a new node here https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php#L227 and then a new test like testEnvWithVariableNode or so 👍

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Apr 14, 2018
@nicolas-grekas
Copy link
Member

@romain-pierre in this very PR please, to reduce the overhead.

@fabpot
Copy link
Member
fabpot commented Apr 16, 2018

Thank you @romain-pierre.

@fabpot fabpot merged commit 9fbdcdb into symfony:master Apr 16, 2018
fabpot added a commit that referenced this pull request Apr 16, 2018
…de (romain-pierre)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Config] Fixes the valid placeholder types for variable node

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | we will see...    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #26894
| License       | MIT

This is a proposition, still in discussion.
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

9fbdcdb Fixes the valid placeholder types for variable node
@ghost ghost deleted the fix/config-varnode branch April 17, 2018 07:55
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