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

Request::getClientIp returns null when running in cli mode #22415

Closed
miklcct opened this issue Apr 13, 2017 · 4 comments
Closed

Request::getClientIp returns null when running in cli mode #22415

miklcct opened this issue Apr 13, 2017 · 4 comments

Comments

@miklcct
Copy link

miklcct commented Apr 13, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.7

Running

(new Symfony\Component\HttpFoundation\Request)->getClientIp();

from cli gets null which violates the PHPDoc saying it return string.

@xabbuh
Copy link
Member

xabbuh commented Apr 13, 2017

While this is true what is the point in asking for the client IP on the CLI where there is no HTTP request at all?

@miklcct
Copy link
Author

miklcct commented Apr 13, 2017

I discovered the bug when a middleware calling this was added into the application stack and called in unit tests, and failed unexpectedly by throwing TypeError because I passed the result directly into a string argument.

@xabbuh
Copy link
Member

xabbuh commented Apr 13, 2017

The only thing we can do is to relax the return type in the docblock as there is no IP address we could return. So that would not really solve your issue.

@miklcct
Copy link
Author

miklcct commented Apr 13, 2017 via email

fabpot added a commit that referenced this issue Apr 13, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[HttpFoundation] Fix getClientIp @return docblock

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22415
| License       | MIT
| Doc PR        | none

Commits
-------

af3424f [HttpFoundation] Fix getClientIp @return docblock
@fabpot fabpot closed this as completed Apr 13, 2017
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