From ccbbbccadbb18a9056d89d347cd72eb77e03a349 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 24 Jan 2018 15:36:00 +0100 Subject: [PATCH] CAvoid calling PRE_COMMAND_RUN if no composer could be initialized --- src/Composer/Command/BaseCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 9e8aacb7d..bd7c8a9fb 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -131,8 +131,10 @@ abstract class BaseCommand extends Command if (null === $composer) { $composer = Factory::createGlobal($this->getIO(), false); } - $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName()); - $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent); + if ($composer) { + $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName()); + $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent); + } if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) { $input->setOption('no-progress', true);