Follow-up for #5205: fix high concurrency race condition
Composer would fail with an ``` PHP temp directory (/tmp) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini ``` error when used in parallel. Because it is checking if a file with `md5(microtime())` can be created, which is not sufficiently unique when used in parallel. Since each Composer instance runs in its own process, this can easily be mitigated by not just partitioning based on time of use, but also based on process ID. Original investigation: https://www.drupal.org/project/automatic_updates/issues/3338789#comment-14961390pull/11386/head
parent
32366bc37d
commit
5d2d513f97
|
@ -339,7 +339,7 @@ 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-' . md5(microtime());
|
||||
$tempfile = sys_get_temp_dir() . '/temp-' . getmypid() . '-' . 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()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue