From 3d2a936dac16d2fd866793d8e64b9196bf3c508f Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 26 Nov 2021 09:15:05 +0900 Subject: [PATCH] fix: is_cli() returns true when $_SERVER['HTTP_USER_AGENT'] is missing Fixes #5336 --- system/Common.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/system/Common.php b/system/Common.php index 32943189b56b..bf91834ac0b1 100644 --- a/system/Common.php +++ b/system/Common.php @@ -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); } }