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

[Process] argv array in env resulting in "Array to string conversion" error #44197

Closed
scuben opened this issue Nov 22, 2021 · 13 comments
Closed

Comments

@scuben
Copy link
Contributor

scuben commented Nov 22, 2021

Symfony version(s) affected

5.3.11

Description

After upgrading the process component from 5.3.7 to 5.3.11 I sometimes get the following error:
Notice: Array to string conversion on https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Process/Process.php#L344

A simple dump($k, $v) showed "argv" and [].

How to reproduce

not sure (yet) but version 5.3.11 required.

Possible Solution

No response

Additional Context

No response

@nicolas-grekas
Copy link
Member

Can you please provide a reproduder for this? I fail to see how this can happen.

@rmj-s
Copy link

rmj-s commented Nov 22, 2021

I'm also facing this issue. is_string check was removed for $_SERVER values in #44070, resulting in argv = [] to be passed here:

$envPairs[] = $k.'='.$v;

@mpiecko
Copy link
Contributor

mpiecko commented Nov 22, 2021

I'm having exact the same Exception "Notice: Array to string conversion" after the update when using Process::fromShellCommandline() ... will try to narrow the issue.

image

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 22, 2021

Thank you all but there is no question whether some of you experience this or not.
The question is rather: how do I reproduce so that I could fix it?
Alternatively, could you please debug where this argv array comes from?
E.g. what does var_dump($env) show for you right before the call to array_intersect_key() in getDefaultEnv()? And just after it?

@mpiecko
Copy link
Contributor

mpiecko commented Nov 22, 2021

Ok, I dumped the $env array in the loop. and it seems this is the item which fails:
"argv" => []

@nicolas-grekas
Copy link
Member

At which line did you dump this please?

@mpiecko
Copy link
Contributor

mpiecko commented Nov 22, 2021

Yes, sorry:

$envPairs[] = $k.'='.$v;

image

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 22, 2021

OK thanks. Can you please try dumping as I suggested in #44197 (comment)?

@mpiecko
Copy link
Contributor

mpiecko commented Nov 22, 2021

This is the only array value from the $env variable:

image

@nicolas-grekas
Copy link
Member

Can you please try #44208?

@mpiecko
Copy link
Contributor

mpiecko commented Nov 22, 2021

Yes, that fixed it 🎉. Just FYI: both items argv and argc where available in an $env dump before and after array_intersect_key() Comment: #44197

nicolas-grekas added a commit that referenced this issue Nov 22, 2021
… (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Process] exclude argv/argc from possible default env vars

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #44197
| License       | MIT
| Doc PR        | -

For some reason `getenv()` can contain these special keys.
Looks a lot like #7196

Commits
-------

36d254a [Process] exclude argv/argc from possible default env vars
@nicolas-grekas
Copy link
Member

Thanks for the help debugging this!

@pks0268
Copy link

pks0268 commented Nov 24, 2021

Notice: Array to string conversion coming on before response from the version 4.4

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

6 participants