From 7048ff3808dd6576628099b53b5b664ec16cba63 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 26 Jan 2024 17:39:30 +0100 Subject: [PATCH] Fix automatic disabling of plugins when running non-interactive as root --- src/Composer/Command/BaseCommand.php | 9 +++++++++ src/Composer/Console/Application.php | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index a33f3a5b3..20d046ee7 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -223,6 +223,15 @@ abstract class BaseCommand extends Command // initialize a plugin-enabled Composer instance, either local or global $disablePlugins = $input->hasParameterOption('--no-plugins'); $disableScripts = $input->hasParameterOption('--no-scripts'); + + $application = parent::getApplication(); + if ($application instanceof Application && $application->getDisablePluginsByDefault()) { + $disablePlugins = true; + } + if ($application instanceof Application && $application->getDisableScriptsByDefault()) { + $disableScripts = true; + } + if ($this instanceof SelfUpdateCommand) { $disablePlugins = true; $disableScripts = true; diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index da77636d1..265f4d7ce 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -657,6 +657,16 @@ class Application extends BaseApplication return $this->initialWorkingDirectory; } + public function getDisablePluginsByDefault(): bool + { + return $this->disablePluginsByDefault; + } + + public function getDisableScriptsByDefault(): bool + { + return $this->disableScriptsByDefault; + } + /** * @return 'prompt'|bool */