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 diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index f6b5a7d94..44ccfa60b 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; @@ -39,7 +40,7 @@ class DiagnoseCommand extends BaseCommand protected $process; /** @var int */ - protected $failures = 0; + protected $exitCode = 0; protected function configure() { @@ -49,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 ) ; @@ -77,6 +80,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); @@ -145,7 +149,7 @@ EOT $this->outputResult($this->checkVersion($config)); } - return $this->failures; + return $this->exitCode; } private function checkComposerSchema() @@ -385,21 +389,41 @@ EOT $io = $this->getIO(); if (true === $result) { $io->write('OK'); + return; + } + + $hadError = false; + 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->exitCode = 2; + } else { + $io->write('WARNING'); + $this->exitCode = 1; + } + + if ($result) { + foreach ($result as $message) { + $io->write($message); + } + } } private function checkPlatform()