Skip to content

Fix exception when convert Request to string #48327

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
wants to merge 1 commit into from

Conversation

tourze
Copy link
Contributor

@tourze tourze commented Nov 25, 2022

In some application like https://github.com/shopware/platform , they will store some data in cookie by an array struct. It will throw an Exception when we try to log the request. This PR fix it.

Q A
Branch? 6.1
Bug fix? yes
New feature? no
Deprecations? no
License MIT

image

image

image

In some application like https://github.com/shopware/platform , they will store some data in cookie by an array struct.
It will throw an Exception when we try to log the request.
This PR fix it.
@xabbuh
Copy link
Member

xabbuh commented Nov 25, 2022

Using arrays as cookie values does not look right to me.

@tourze
Copy link
Contributor Author

tourze commented Nov 25, 2022

Using arrays as cookie values does not look right to me.

I agree with you, but some developer like to do it, and it is not forbid in symfony. You can see that profiler page can decode the array cookie correctly.

@MatTheCat
Copy link
Contributor

MatTheCat commented Dec 3, 2022

This is indeed a “feature” of PHP:

Cookies names can be set as array names and will be available to your PHP scripts as arrays

https://www.php.net/manual/en/function.setcookie.php#refsect1-function.setcookie-notes

@tourze bugfixes should also include test cases which would fail without them; could you do so in HttpFoundation’s RequestTest?

@nicolas-grekas
Copy link
Member

Thank you for reporting and giving this PR a try. I submitted #48628 instead, which should be a bit more robust + is tested. Closing therefor.

nicolas-grekas added a commit that referenced this pull request Dec 13, 2022
This PR was merged into the 5.4 branch.

Discussion
----------

[HttpFoundation] Fix dumping array cookies

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

See https://www.php.net/manual/en/function.setcookie.php#refsect1-function.setcookie-notes

Commits
-------

3cf4401 [HttpFoundation] Fix dumping array cookies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants