From af4b74d3329c634aace5d25eafa03059cee2a3db Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 11 Dec 2024 09:25:02 +0100 Subject: [PATCH] Update logic --- bin/composer | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/composer b/bin/composer index 93d3554ba..94785c85e 100755 --- a/bin/composer +++ b/bin/composer @@ -39,12 +39,11 @@ if (!extension_loaded('iconv') && !extension_loaded('mbstring')) { } if (function_exists('ini_set')) { - // if display_errors is set to stderr or unset, we set it - if ('stderr' !== ini_get('display_errors') && !(bool) ini_get('display_errors')) { - // except if we're on a CLI SAPI with log errors enabled and the error_log is empty, in which case errors already go to stderr - if (!(bool) ini_get('log_errors') || PHP_SAPI !== 'cli' || '' !== ini_get('error_log')) { - @ini_set('display_errors', PHP_SAPI === 'cli' ? 'stderr' : '1'); - } + // check if error logging is on, but to an empty destination - for the CLI SAPI, that means stderr + $logsToSapiDefault = ('' === ini_get('error_log') && (bool) ini_get('log_errors')); + // on the CLI SAPI, ensure errors are displayed on stderr, either via display_errors or via error_log + if (PHP_SAPI === 'cli') { + @ini_set('display_errors', $logsToSapiDefault ? '0' : 'stderr'); } // Set user defined memory limit