1
0
Fork 0

Fix getmypid being required as it is not always available, fixes #11401

pull/11459/head
Jordi Boggiano 2023-05-07 14:48:34 +02:00
parent bf5ae27b93
commit 2b58f2c625
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 2 additions and 1 deletions

View File

@ -339,7 +339,8 @@ class Application extends BaseApplication
// Check system temp folder for usability as it can cause weird runtime issues otherwise
Silencer::call(static function () use ($io): void {
$tempfile = sys_get_temp_dir() . '/temp-' . getmypid() . '-' . md5(microtime());
$pid = function_exists('getmypid') ? getmypid() . '-' : '';
$tempfile = sys_get_temp_dir() . '/temp-' . $pid . md5(microtime());
if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
$io->writeError(sprintf('<error>PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini</error>', sys_get_temp_dir()));
}