Skip to content

Commit

Permalink
fix: is_cli() returns true when $_SERVER['HTTP_USER_AGENT'] is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 26, 2021
1 parent 0a55082 commit 3d2a936
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions system/Common.php
Expand Up @@ -643,16 +643,7 @@ function helper($filenames)
*/
function is_cli(): bool
{
if (defined('STDIN')) {
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']);
return in_array(PHP_SAPI, ['cli', 'phpdbg'], true);
}
}

Expand Down

0 comments on commit 3d2a936

Please sign in to comment.