From b729da69fc0fa0dc749183f3bd2de2f0a1023ac0 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Sun, 28 Jan 2024 13:32:25 -0800 Subject: [PATCH] Improve CLI check, added PHP dev server to sentry helper (#2105) --- src/library/FOSSBilling/Environment.php | 2 +- src/library/FOSSBilling/SentryHelper.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/library/FOSSBilling/Environment.php b/src/library/FOSSBilling/Environment.php index 511a46d14..67efff83e 100644 --- a/src/library/FOSSBilling/Environment.php +++ b/src/library/FOSSBilling/Environment.php @@ -60,6 +60,6 @@ class Environment */ public static function isCLI(): bool { - return php_sapi_name() === 'cli' || !http_response_code(); + return PHP_SAPI === 'cli' || defined('STDIN') || !http_response_code(); } } diff --git a/src/library/FOSSBilling/SentryHelper.php b/src/library/FOSSBilling/SentryHelper.php index 2d6d71ee1..3d9fdfdd1 100644 --- a/src/library/FOSSBilling/SentryHelper.php +++ b/src/library/FOSSBilling/SentryHelper.php @@ -52,7 +52,8 @@ class SentryHelper { $sentryDSN = '--replace--this--during--release--process--'; - $httpClient = new class() implements HttpClientInterface { + $httpClient = new class() implements HttpClientInterface + { public function sendRequest(Request $request, Options $options): Response { $dsn = $options->getDsn(); @@ -179,6 +180,8 @@ class SentryHelper return 'Litespeed'; } elseif (stripos(strtolower($serverSoftware), 'nginx') !== false) { return 'NGINX'; + } elseif (PHP_SAPI === 'cli-server') { + return 'PHP Development Server'; } else { return 'Unknown'; }