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

more robust initialization from request #34649

Merged
merged 1 commit into from Nov 30, 2019
Merged

more robust initialization from request #34649

merged 1 commit into from Nov 30, 2019

Conversation

dbu
Copy link
Contributor

@dbu dbu commented Nov 27, 2019

Request::getPort is declared as int|string but can actually return null.

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

I discovered this problem with a functional test where i dispatch the RequestEvent with a new Request(). This used to work in symfony 4 and now triggers an error Argument 1 passed to Symfony\Component\Routing\RequestContext::setHttpPort() must be of the type int, null given

In regular web requests, this should probably never happen, but it seems to me if Request is not robust, the RequestContext should be robust about it.

@dbu
Copy link
Contributor Author

dbu commented Nov 27, 2019

hm, should i have done this against the 5.0 branch? i will port the fix there if maintainers agree with the fix...

@nicolas-grekas
Copy link
Member

This looks like something for 3.4 to me.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Nov 27, 2019
Request::getPort is declared as int|string but can actually return null.
@dbu
Copy link
Contributor Author

dbu commented Nov 28, 2019

o wow :-D
guess it only became visible now with the strict type declarations... anything i can help further, or do you pick it up from here? i see that the ci is failing but it does not look related.

@fabpot
Copy link
Member

fabpot commented Nov 30, 2019

Thank you @dbu.

fabpot added a commit that referenced this pull request Nov 30, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

more robust initialization from request

Request::getPort is declared as int|string but can actually return null.

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

I discovered this problem with a functional test where i dispatch the RequestEvent with a `new Request()`. This used to work in symfony 4 and now triggers an error `Argument 1 passed to Symfony\Component\Routing\RequestContext::setHttpPort() must be of the type int, null given`

In regular web requests, this should probably never happen, but it seems to me if Request is not robust, the RequestContext should be robust about it.

Commits
-------

c6ed0f0 more robust initialization from request
@fabpot fabpot merged commit c6ed0f0 into symfony:3.4 Nov 30, 2019
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.

None yet

4 participants