From cfdeb617791929f03c47f1b18994ad0429704f51 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 12 Sep 2016 11:00:10 +0200 Subject: [PATCH 1/4] Avoid warning when testing for packagist over http --- src/Composer/Command/DiagnoseCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index f6b5a7d94..dbfad7829 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -24,6 +24,7 @@ use Composer\Util\RemoteFilesystem; use Composer\Util\StreamContextFactory; use Composer\SelfUpdate\Keys; use Composer\SelfUpdate\Versions; +use Composer\IO\NullIO; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -77,6 +78,7 @@ EOT } $config->merge(array('config' => array('secure-http' => false))); + $config->prohibitUrlByConfig('http://packagist.org', new NullIO); $this->rfs = Factory::createRemoteFilesystem($io, $config); $this->process = new ProcessExecutor($io); From b29d810d63f6c2a6a6be0bfd063ae8b722c2629d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 12 Sep 2016 11:00:38 +0200 Subject: [PATCH 2/4] Only treat errors as real failures, fixes #5601 --- src/Composer/Command/DiagnoseCommand.php | 41 +++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index dbfad7829..9dccfced3 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -385,23 +385,42 @@ EOT private function outputResult($result) { $io = $this->getIO(); + $hadError = false; if (true === $result) { $io->write('OK'); + return; + } + + if ($result instanceof \Exception) { + $result = '['.get_class($result).'] '.$result->getMessage().''; + } + + if (!$result) { + // falsey results should be considered as an error, even if there is nothing to output + $hadError = true; } else { - $this->failures++; - $io->write('FAIL'); - if ($result instanceof \Exception) { - $io->write('['.get_class($result).'] '.$result->getMessage()); - } elseif ($result) { - if (is_array($result)) { - foreach ($result as $message) { - $io->write($message); - } - } else { - $io->write($result); + if (!is_array($result)) { + $result = array($result); + } + foreach ($result as $message) { + if (false !== strpos($message, '')) { + $hadError = true; } } } + + if ($hadError) { + $io->write('FAIL'); + $this->failures++; + } else { + $io->write('WARNING'); + } + + if ($result) { + foreach ($result as $message) { + $io->write($message); + } + } } private function checkPlatform() From a04256810e729d0be6a3d457658f3879e07f6988 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 12 Sep 2016 11:25:43 +0200 Subject: [PATCH 3/4] Change exit code to be 1/2 for warn/fail, refs #5601 --- src/Composer/Command/DiagnoseCommand.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 9dccfced3..44ccfa60b 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -40,7 +40,7 @@ class DiagnoseCommand extends BaseCommand protected $process; /** @var int */ - protected $failures = 0; + protected $exitCode = 0; protected function configure() { @@ -50,6 +50,8 @@ class DiagnoseCommand extends BaseCommand ->setHelp(<<diagnose command checks common errors to help debugging problems. +The process exit code will be 1 in case of warnings and 2 for errors. + EOT ) ; @@ -147,7 +149,7 @@ EOT $this->outputResult($this->checkVersion($config)); } - return $this->failures; + return $this->exitCode; } private function checkComposerSchema() @@ -385,12 +387,12 @@ EOT private function outputResult($result) { $io = $this->getIO(); - $hadError = false; if (true === $result) { $io->write('OK'); return; } + $hadError = false; if ($result instanceof \Exception) { $result = '['.get_class($result).'] '.$result->getMessage().''; } @@ -411,9 +413,10 @@ EOT if ($hadError) { $io->write('FAIL'); - $this->failures++; + $this->exitCode = 2; } else { $io->write('WARNING'); + $this->exitCode = 1; } if ($result) { From 568108da28f3ce24e0871ba70b2474ef8237f9f3 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 12 Sep 2016 11:25:56 +0200 Subject: [PATCH 4/4] Prepare 1.2.1 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cfc464fe..f9c39c157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### [1.2.1] - 2016-09-12 + + * Fixed edge case issues with the static autoloader + * Minor fixes + ### [1.2.0] - 2016-07-19 * Security: Fixed [httpoxy](https://httpoxy.org/) vulnerability