-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: is_cli()
returns true
when $_SERVER['HTTP_USER_AGENT']
is missing
#5393
Conversation
These were changes pretty recently by @paulbalandan to address other issues - he should take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to approach this. The recent changes in the is_cli()
method were to account for cron jobs running in php-cgi
(#4699 fixed by #4725), edge case in #4739, as well as #4843 and #4848. Obviously, accepting this fix would fail cronjobs in cgi fixed previously.
I still believe the proper fix for this is in my #5336 (comment) by expanding the isset
calls. Also, seen in StackOverflow https://stackoverflow.com/a/25967493
@paulbalandan I added conditions. I removed |
#4739 was raised by @najdanovicivan in the Slack channel. I cannot remember the issue then, but adding the |
Searched slack, and I found Ivan said the following causes the issue. if (! isset($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']))
{
return true;
} And said The following is the fixed code at that time: if (PHP_SAPI === 'cli')
{
return true;
}
if (defined('STDIN'))
{
return true;
}
if (stristr(PHP_SAPI, 'cgi') && getenv('TERM'))
{
return true;
}
if (! isset($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']) && isset($_SERVER['argv']) && count($_SERVER['argv']) > 0)
{
return true;
}
// if source of request is from CLI, the `$_SERVER` array will not populate this key
return ! isset($_SERVER['REQUEST_METHOD']); |
@najdanovicivan Do you have any problem with this PR? |
All good here. I had issues with some web requests being treated as CLI due to missing HTTP_USER_AGENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all involved parties are okay with this, then it is good to go.
💪 |
Description
Fixes #5336
Checklist: