8000 [DependencyInjection] Fix autocasting null env values to empty string by fancyweb · Pull Request #50837 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Fix autocasting null env values to empty string #50837

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

Conversation

fancyweb
Copy link
Contributor
@fancyweb fancyweb commented Jun 30, 2023
Q A
Branch? 5.4
Bug fix? yes
New feature? -
Deprecations? -
Tickets #50815 (comment)
License MIT
Doc PR -

This PR fixes autocasting null env values to ''.
We continue to autocast all other values to string when there's no prefix.

It doesn't revert #50517, it just fixes an unintended side effect.

It doesn't fix #50815 request, it confirms the behavior: the solution for this issue would be to remove the string: prefix.

There's still no solution to have the "keep null as null" and "cast if not null" behavior.

@carsonbot carsonbot added this to the 5.4 milestone Jun 30, 2023
@fancyweb fancyweb force-pushed the di/fix-autocast-null-env-to-empty-string branch from 3b996e9 to 7fd7de2 Compare June 30, 2023 16:28
@fancyweb fancyweb force-pushed the di/fix-autocast-null-env-to-empty-string branch 2 times, most recently from 764d623 to 07f00e1 Compare June 30, 2023 16:42
@@ -126,6 +126,12 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
}
}

$returnNull = false;
if ('' === $prefix) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

'' becomes a magic value that acts as the string prefix except for null where we return null

@fancyweb fancyweb force-pushed the di/fix-autocast-null-env-to-empty-string branch 2 times, most recently from d42f633 to 024526a Compare June 30, 2023 17:37
@nicolas-grekas nicolas-grekas force-pushed the di/fix-autocast-null-env-to-empty-string branch from 024526a to 2c0815d Compare July 3, 2023 12:55
@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit 1e1d91e into symfony:5.4 Jul 3, 2023