From 3e7b826904b28fa534f32a8a1b727a514e24bdc7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 17 Sep 2024 09:47:20 +0200 Subject: [PATCH] Avoid opening php://stdin multiple times, fixes #12107 --- src/Composer/Console/Application.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 64166a982..3a784f8a8 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -153,7 +153,10 @@ class Application extends BaseApplication $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins'); $this->disableScriptsByDefault = $input->hasParameterOption('--no-scripts'); - $stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r'); + static $stdin = null; + if (null === $stdin) { + $stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r'); + } if (Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') !== '1' && (Platform::getEnv('COMPOSER_NO_INTERACTION') || $stdin === false || !Platform::isTty($stdin))) { $input->setInteractive(false); }