From c2e768b8ad8d03e2076dba48ea52d52bd60238f1 Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Tue, 26 Jan 2016 13:27:24 +0100 Subject: [PATCH] Made Silencer invocations safer against exceptions. --- src/Composer/Command/ConfigCommand.php | 6 ++---- src/Composer/Command/CreateProjectCommand.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 7f4fde6d4..87fdc4ffb 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -159,18 +159,16 @@ EOT $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true); // Initialize the global file if it's not there, ignoring any warnings or notices - Silencer::suppress(); if ($input->getOption('global') && !$this->configFile->exists()) { touch($this->configFile->getPath()); $this->configFile->write(array('config' => new \ArrayObject)); - chmod($this->configFile->getPath(), 0600); + Silencer::call('chmod', $this->configFile->getPath(), 0600); } if ($input->getOption('global') && !$this->authConfigFile->exists()) { touch($this->authConfigFile->getPath()); $this->authConfigFile->write(array('http-basic' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject)); - chmod($this->authConfigFile->getPath(), 0600); + Silencer::call('chmod', $this->authConfigFile->getPath(), 0600); } - Silencer::restore(); if (!$this->configFile->exists()) { throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile)); diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index df50c4750..dbb7f6802 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -225,13 +225,11 @@ EOT chdir($oldCwd); $vendorComposerDir = $composer->getConfig()->get('vendor-dir').'/composer'; if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) { - Silencer::suppress(); - rmdir($vendorComposerDir); + Silencer::call('rmdir', $vendorComposerDir); $vendorDir = $composer->getConfig()->get('vendor-dir'); if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) { - rmdir($vendorDir); + Silencer::call('rmdir', $vendorDir); } - Silencer::restore(); } return 0;