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

[DI] Remove default env type check on validate#27470

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

Closed
ro0NL wants to merge1 commit intosymfony:4.1fromro0NL:di/env-type
Closed

[DI] Remove default env type check on validate#27470

ro0NL wants to merge1 commit intosymfony:4.1fromro0NL:di/env-type

Conversation

@ro0NL
Copy link
Contributor

QA
Branch?4.1
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#27455
LicenseMIT
Doc PRsymfony/symfony-docs#...

The default env is already validated to be a scalar or null onget()

'scalar_node' =>'%env(NULLED)%',
'int_node' =>'%env(int:FOO)%',
'float_node' =>'%env(float:BAR)%',
'float_node' =>'%env(FLOATISH)%',
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

currently this fails, im not sure what we expect here. Env without a prefix is now assumed to be a scalar which is not allowed for float-only node.

Copy link
Member

@nicolas-grekasnicolas-grekasJun 1, 2018
edited
Loading

Choose a reason for hiding this comment

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

shouldn't we useis_numeric() somewhere?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It's a scalar issue in general, directly related to

if (null !==$defaultValue && !is_scalar($defaultValue)) {
thrownewRuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".',gettype($defaultValue),$name));
}

im not sure what's the behavior we're seeking... what does "env without prefix" mean on its value? It if can be any scalar then using it for a float node is invalid, technically.

to make it work we should simply avoid the type check in config for this case, but it makes validation less strict.

Choose a reason for hiding this comment

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

Would it be possible to prefix a processor here? Referencing the envelope bar with float: prepended?

Copy link
Member

Choose a reason for hiding this comment

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

Well, the thing is, without thefloat cast in the env var retrieval, the service would not receive a float, but a string. Sofloat_node not accepting%env(FLOATISH)% is expected to me.

@nicolas-grekasnicolas-grekas added this to the4.1 milestoneJun 1, 2018
@ro0NL
Copy link
ContributorAuthor

bc break resolved, instead of using a string typed placeholder it now preserves the actual env type

@nicolas-grekas
Copy link
Member

Thank you@ro0NL.

@teohhanhui
Copy link
Contributor

Will you add any tests to prevent regressions? :D

@ro0NL
Copy link
ContributorAuthor

@teohhanhui what do you propose? tests are updated as such ...

teohhanhui reacted with thumbs up emoji

@teohhanhui
Copy link
Contributor

Sorry, I somehow overlooked that. 🙇‍♂️

@SoboLAN
Copy link

I'm sorry, but this just broke my project and I had to spend like a few hours trying to figure out what was going on.

In my config files I had stuff like:

some_bundle:    key1:        subkey:            value: '%env(MY_URL)%'    key2:        subkey:            value: '%env(MY_OTHER_URL)%'

Those env-vars were defined in.env file. And it worked perfectly fine.

Upgradingsymfony/dependency-injection from 4.1.0 to 4.1.6 broke it because now the configuration validation in that 3rd-party bundle complains that those values are not strings.

Only by adding thestring: suffix was I able to warmup Symfony's cache.

Breaking BC like this isNOT OK, especially when incrementing only patch version !!

@ro0NL
Copy link
ContributorAuthor

ro0NL commentedOct 30, 2018
edited
Loading

it had to be done to prevent another BC break between 3.x and 4.x:#27455

so 4.1.0 is the wrong behavior, and fixed as of 4.1.6.. but i understand being in between was not convenient for you :(

symfony-splitter pushed a commit to symfony/dependency-injection that referenced this pull requestMar 27, 2019
This PR was merged into the 4.3-dev branch.Discussion----------[DI] Deprecate non-string default envs| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes-ish| New feature?  | yes| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | yes| Tests pass?   | no    <!-- please add some, will be required by reviewers -->| Fixed tickets | #27680,symfony/symfony#27470 (comment)| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->This is a failing test to further clarify the issues raised in #27680So givensymfony/symfony#27680 (comment)> We should be sure this solves a real-world issue.I think it solves a real bug :)Commits-------2311437c9f [DI] Deprecate non-string default envs
fabpot added a commit that referenced this pull requestMar 27, 2019
This PR was merged into the 4.3-dev branch.Discussion----------[DI] Deprecate non-string default envs| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes-ish| New feature?  | yes| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | yes| Tests pass?   | no    <!-- please add some, will be required by reviewers -->| Fixed tickets |#27680,#27470 (comment)| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->This is a failing test to further clarify the issues raised in#27680So given#27680 (comment)> We should be sure this solves a real-world issue.I think it solves a real bug :)Commits-------2311437 [DI] Deprecate non-string default envs
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

6 participants

@ro0NL@nicolas-grekas@teohhanhui@SoboLAN@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp