Skip to content

Commit

Permalink
Workaround PHP bug with env vars not being read correctly on Windows, f…
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jan 7, 2022
1 parent 9360e2c commit 65c8daa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/composer
Expand Up @@ -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'));

This comment has been minimized.

Copy link
@johnstevenson

johnstevenson Jan 7, 2022

Member

getenv() without a param is PHP 7.1 and this is on the 2.2 branch which allows lower versions ?

This comment has been minimized.

Copy link
@Seldaek

Seldaek Jan 7, 2022

Author Member

Oh I wasn't aware.. On the other hand getenv was also borked for versions before that, so we can simply skip this code on php<7.1 I'd say. Makes sense?

This comment has been minimized.

Copy link
@johnstevenson

johnstevenson Jan 7, 2022

Member

Yeah, that makes sense.

}

Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));

ErrorHandler::register();
Expand Down

0 comments on commit 65c8daa

Please sign in to comment.