Skip to content
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

PHP warning when using %env(default::FOO)% #32853

Closed
BenMorel opened this issue Aug 1, 2019 · 1 comment
Closed

PHP warning when using %env(default::FOO)% #32853

BenMorel opened this issue Aug 1, 2019 · 1 comment

Comments

@BenMorel
Copy link
Contributor

BenMorel commented Aug 1, 2019

Symfony version(s) affected: 4.3.3

Description

When using the %env(default::FOO)% environment variable processor to get the value or NULL, the app fails with a PHP warning:

Warning: array_key_exists() expects parameter 2 to be array, null given

The bug only happens when the env var is not defined, and only the first time you load a page; after that, it works and the parameter is correctly set to null when the env var is not set.

Running cache:clear does trigger the bug every time, though.

How to reproduce

  • create a new project: symfony new bug && cd bug
  • edit config/services.yaml and add the following:
    parameters:
        app.foo: '%env(default::APP_FOO)%'
  • run bin/console cache:clear
@ABGEO
Copy link
Contributor

ABGEO commented Aug 1, 2019

Hello,

I will try to fix this issue :)

nicolas-grekas added a commit that referenced this issue Aug 3, 2019
This PR was submitted for the 4.3 branch but it was squashed and merged into the 3.4 branch instead (closes #32870).

Discussion
----------

| Q             | A
| ------------- | ---
| Branch?     | 4.3
| Bug fix?      | yes
| New feature?  | no
| Tests pass?   | yes
| Fixed tickets | #32853
| License       | MIT

Commits
-------

7cf9ed6 #32853 Check if $this->parameters is array.
nicolas-grekas added a commit that referenced this issue Aug 3, 2019
* 3.4:
  #32853 Check if $this->parameters is array.
  [Validator] Improve Fa translations
nicolas-grekas added a commit that referenced this issue Aug 3, 2019
* 4.3:
  #32853 Check if $this->parameters is array.
  [Validator] Improve Fa translations
nicolas-grekas added a commit that referenced this issue Aug 3, 2019
* 4.4:
  #32853 Check if $this->parameters is array.
  [Mailer] added debug info on HTTP transport exceptions
  [Validator] Improve Fa translations
This was referenced Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants