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

[Profiler] Fix profiler nullable string type #36162

Merged
merged 1 commit into from Apr 21, 2020
Merged

[Profiler] Fix profiler nullable string type #36162

merged 1 commit into from Apr 21, 2020

Conversation

mRoca
Copy link
Contributor

@mRoca mRoca commented Mar 21, 2020

Q A
Branch? 5.0
Bug fix? yes
New feature? no
Deprecations? no
Tickets n/a
License MIT
Doc PR -

This PR fixes nullable string types in setter for the Profile class.

The detected issue comes from the Profiler class :

$profile->setIp($request->getClientIp()); // string or null

The corresponding return types for the Profile getters are allready good:

    /**
     * Returns the IP.
     *
     * @return string|null The IP
     */
    public function getIp()
    {
        return $this->ip;
    }

@Kocal
Copy link
Contributor

Kocal commented Mar 21, 2020

Or maybe we can call ->setIp() only when $request->getClientIp() is not null?

@nicolas-grekas nicolas-grekas added this to the 5.0 milestone Mar 23, 2020
@nicolas-grekas
Copy link
Member

Setting the IP or URL to null doesn't look useful from the pov of the API, does it? How did you spot this?

@mRoca
Copy link
Contributor Author

mRoca commented Mar 23, 2020

I've spotted it by calling the fpm agent with cgi-fcgi (for container cache warmup & docker healthcheck):

REDIRECT_STATUS=true SCRIPT_FILENAME=/srv/public/index.php HTTP_HOST=127.0.0.1 REQUEST_URI=/ REQUEST_METHOD=GET HTTP_USER_AGENT=probe cgi-fcgi -bind -connect 127.0.0.1:9001

This line command won't work because of this type bug, as $request->getClientIp() parses the $_SERVER['REMOTE_ADDR'] value. But if I add the corresponding header REMOTE_ADDR=127.0.0.1 to the command, everything is fine.

@fabpot
Copy link
Member

fabpot commented Apr 21, 2020

Thank you @mRoca.

@fabpot fabpot merged commit 22f1076 into symfony:5.0 Apr 21, 2020
@mRoca mRoca deleted the fix_profile_set_ip_type branch April 22, 2020 09:03
@fabpot fabpot mentioned this pull request Apr 28, 2020
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

5 participants