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

Skip to content

[DependencyInjection][Bug] Environment variables incorrectly makes placeholder an array #20213

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

Closed
mickadoo opened this issue Oct 13, 2016 · 0 comments

Comments

@mickadoo
Copy link
Contributor

Following code review changes on #20199 (review) I reverted the mergeEnvPlaceholders. However I think I probably shouldn't have changed it as it seems to be broken now. array_merge_recursive will create this structure when the placeholder is initialized inside EnvPlaceholderParameterBag::get()

[
  'DB_DRIVER' => 
  [
    'env_DB_DRIVER_uniq_string' => 'env_DB_DRIVER_uniq_string',
  ],
]

And then once mergeEnvPlaceholders is called it results in

[
  'DB_DRIVER' =>
    [
      'env_DB_DRIVER_uniq_string' => 
      [
        0 => 'env_DB_DRIVER_uniq_string',
        1 => 'env_DB_DRIVER_uniq_string',
      ],
   ]
]

Which causes an error inside ContainerBuilder::resolveEnvPlaceholders as the placeholder is an array instead of a string.

ContextErrorException in ContainerBuilder.php line 1045: Warning: stripos(): needle is not a string or an integer

I don't think this can be fixed inside the envPlaceholders assignment because it's an issue related to the merging of two parameter bags, not the assignment of them. I would suggest using the original fix I proposed inside mergeEnvPlaceholders

nicolas-grekas added a commit that referenced this issue Oct 14, 2016
…adoo)

This PR was squashed before being merged into the 3.2-dev branch (closes #20214).

Discussion
----------

Fix/broken merging of parameter bag env placeholders

| Q             | A
| ------------- | ---
| Branch?       | "master"
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20213
| License       | MIT
| Doc PR        | reference to the documentation PR, if any

In PR #20199 I made changes after review that broke the use of env variables, sorry about that - should have checked it a bit more before making the changes.

@nicolas-grekas, I know you're very busy with all that merging, but if you could take a look at this it would be great since you know most about it.

Commits
-------

b53e0de Fix/broken merging of parameter bag env placeholders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants