Skip to content

Commit 00fc585

Browse files
committed
fix: handle edge case of 'cgi-fcgi' and 'fpm-fcgi'
1 parent 29f8bf8 commit 00fc585

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

system/Common.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,13 @@ function helper($filenames)
643643
*/
644644
function is_cli(): bool
645645
{
646-
return in_array(PHP_SAPI, ['cli', 'phpdbg'], true);
646+
if (in_array(PHP_SAPI, ['cli', 'phpdbg'], true)) {
647+
return true;
648+
}
649+
650+
// PHP_SAPI could be 'cgi-fcgi', 'fpm-fcgi'.
651+
// See https://github.com/codeigniter4/CodeIgniter4/pull/5393
652+
return ! isset($_SERVER['REMOTE_ADDR']) && ! isset($_SERVER['REQUEST_METHOD']);
647653
}
648654
}
649655

0 commit comments

Comments
 (0)