You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
A php notice appears in DotEnv when dealing with empty default env variables:
PHP Notice: Uninitialized string offset: 1 in /vendor/symfony/dotenv/Dotenv.php on line 477
if ('' === $value && isset($matches['default_value'])) {
$unsupportedChars = strpbrk($matches['default_value'], '\'"{$');
if (false !== $unsupportedChars) {
throw$this->createFormatException(sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name));
}
$value = substr($matches['default_value'], 2);
if ('=' === $matches['default_value'][1]) { // Here is the notice$this->values[$name] = $value;
}
}
The issue is that $matches['default_value'] is equal to an empty string, not an array.
I'm not sure I'm allowed to use such notation for an env variable.
So maybe we should check that $matches['default_value'] is an array and throw an exception if not (and update the documentation?).
Or it could be an empty string and in this case, we should verify the $matches['default_value'] type before going further.
I will be more than happy to do a PR for that, I just need more insight on what to do
The text was updated successfully, but these errors were encountered:
… (xabbuh)
This PR was merged into the 4.4 branch.
Discussion
----------
[Dotenv] don't fail when referenced env var does not exist
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#34537
| License | MIT
| Doc PR |
Commits
-------
8026609 don't fail when referenced env var does not exist
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: >= 4.4
Description
A php notice appears in DotEnv when dealing with empty default env variables:
PHP Notice: Uninitialized string offset: 1 in
/vendor/symfony/dotenv/Dotenv.php
on line 477The issue is that
$matches['default_value']
is equal to an empty string, not an array.In my case:
It's maybe due to how we wrote our env variable. The issue happens when resolving
MESSENGER_DSN
:Possible Resolution
I'm not sure I'm allowed to use such notation for an env variable.
So maybe we should check that
$matches['default_value']
is an array and throw an exception if not (and update the documentation?).Or it could be an empty string and in this case, we should verify the
$matches['default_value']
type before going further.I will be more than happy to do a PR for that, I just need more insight on what to do
The text was updated successfully, but these errors were encountered: