Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Fix support for false boolean env vars #50530

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
Jun 9, 2023

Conversation

Okhoshi
Copy link
Contributor

@Okhoshi Okhoshi commented Jun 1, 2023

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

After upgrading symfony/dependency-injection package to version 6.3, some of our env vars couldn't be found anymore.

For some scripts, we are providing an adhoc default value to env vars by setting $_SERVER directly. However, since version 6.3 of the DependencyInjection component, setting an env var to false (the boolean value, like in the snippet below) doesn't work anymore, and Symfony reports that the variable cannot be found.

$_SERVER['FOO'] = false;

It seems to be a side effect of the changes made in #48705.

@stof
Copy link
Member

stof commented Jun 1, 2023

environment variables are always strings though. What you are covering in tests is not something compatible with actual environment variables (or with the DotEnv component).

@Okhoshi
Copy link
Contributor Author

Okhoshi commented Jun 1, 2023

Because you can set any scalar value from PHP code, and they won't be converted to strings nor anything will prevent you to set them in the first place. FWIW, we've never had any troubles so far, be it with Symfony or DotEnv component.

I'm covering with tests because it was a supported behaviour that has been broken with 6.3 release. If you think it shouldn't have been supported from the start, and thus that this is not a bug, I'm also fine with that, feel free to let me know and close this PR.
But it's not really consistent then since any other scalar value will work.

@stof
Copy link
Member

stof commented Jun 1, 2023

It was not a supported behavior. It was an undefined behavior that happened to work.

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.

Works for me, I'm fine keeping the behavior from 6.2.

@nicolas-grekas
Copy link
Member

Thank you @Okhoshi.

@nicolas-grekas nicolas-grekas merged commit 87a65d8 into symfony:6.3 Jun 9, 2023
@Okhoshi Okhoshi deleted the di-false-env branch June 13, 2023 18:11
@fabpot fabpot mentioned this pull request Jun 26, 2023
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.

4 participants