We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5dcad2c + 00fc585 commit b5478b3Copy full SHA for b5478b3
1 file changed
system/Common.php
@@ -643,16 +643,13 @@ function helper($filenames)
643
*/
644
function is_cli(): bool
645
{
646
- if (defined('STDIN')) {
+ if (in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) {
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']);
+ // PHP_SAPI could be 'cgi-fcgi', 'fpm-fcgi'.
+ // See https://github.com/codeigniter4/CodeIgniter4/pull/5393
+ return ! isset($_SERVER['REMOTE_ADDR']) && ! isset($_SERVER['REQUEST_METHOD']);
656
657
658
0 commit comments