Skip to content

Commit 29f8bf8

Browse files
committed
fix: is_cli() returns true when $_SERVER['HTTP_USER_AGENT'] is missing
Fixes #5336
1 parent 76ad2ad commit 29f8bf8

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

system/Common.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,7 @@ function helper($filenames)
643643
*/
644644
function is_cli(): bool
645645
{
646-
if (defined('STDIN')) {
647-
return true;
648-
}
649-
650-
if (! isset($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']) && isset($_SERVER['argv']) && count($_SERVER['argv']) > 0) {
651-
return true;
652-
}
653-
654-
// if source of request is from CLI, the `$_SERVER` array will not populate this key
655-
return ! isset($_SERVER['REQUEST_METHOD']);
646+
return in_array(PHP_SAPI, ['cli', 'phpdbg'], true);
656647
}
657648
}
658649

0 commit comments

Comments
 (0)