From 65c8daa969309e5d9f526f28427bff4b77e417bf Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 7 Jan 2022 09:17:25 +0100 Subject: [PATCH] Workaround PHP bug with env vars not being read correctly on Windows, fixes #10434 refs https://github.com/php/php-src/issues/7896 --- bin/composer | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/composer b/bin/composer index cee476b6d..32c45bcda 100755 --- a/bin/composer +++ b/bin/composer @@ -65,6 +65,12 @@ if (function_exists('ini_set')) { unset($memoryLimit); } +// Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER +// see https://github.com/php/php-src/issues/7896 +if (Platform::isWindows()) { + $_SERVER = array_merge($_SERVER, array_intersect_ukey($_SERVER, getenv(), 'strcasecmp')); +} + Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0])); ErrorHandler::register();