Merge branch '1.2'

main
Jordi Boggiano 8 years ago
commit 754d4fa1b2

@ -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 ### [1.2.0] - 2016-07-19
* Security: Fixed [httpoxy](https://httpoxy.org/) vulnerability * Security: Fixed [httpoxy](https://httpoxy.org/) vulnerability

@ -24,6 +24,7 @@ use Composer\Util\RemoteFilesystem;
use Composer\Util\StreamContextFactory; use Composer\Util\StreamContextFactory;
use Composer\SelfUpdate\Keys; use Composer\SelfUpdate\Keys;
use Composer\SelfUpdate\Versions; use Composer\SelfUpdate\Versions;
use Composer\IO\NullIO;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -39,7 +40,7 @@ class DiagnoseCommand extends BaseCommand
protected $process; protected $process;
/** @var int */ /** @var int */
protected $failures = 0; protected $exitCode = 0;
protected function configure() protected function configure()
{ {
@ -49,6 +50,8 @@ class DiagnoseCommand extends BaseCommand
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>diagnose</info> command checks common errors to help debugging problems. The <info>diagnose</info> command checks common errors to help debugging problems.
The process exit code will be 1 in case of warnings and 2 for errors.
EOT EOT
) )
; ;
@ -77,6 +80,7 @@ EOT
} }
$config->merge(array('config' => array('secure-http' => false))); $config->merge(array('config' => array('secure-http' => false)));
$config->prohibitUrlByConfig('http://packagist.org', new NullIO);
$this->rfs = Factory::createRemoteFilesystem($io, $config); $this->rfs = Factory::createRemoteFilesystem($io, $config);
$this->process = new ProcessExecutor($io); $this->process = new ProcessExecutor($io);
@ -145,7 +149,7 @@ EOT
$this->outputResult($this->checkVersion($config)); $this->outputResult($this->checkVersion($config));
} }
return $this->failures; return $this->exitCode;
} }
private function checkComposerSchema() private function checkComposerSchema()
@ -385,21 +389,41 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
if (true === $result) { if (true === $result) {
$io->write('<info>OK</info>'); $io->write('<info>OK</info>');
return;
}
$hadError = false;
if ($result instanceof \Exception) {
$result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
}
if (!$result) {
// falsey results should be considered as an error, even if there is nothing to output
$hadError = true;
} else { } else {
$this->failures++; if (!is_array($result)) {
$io->write('<error>FAIL</error>'); $result = array($result);
if ($result instanceof \Exception) { }
$io->write('['.get_class($result).'] '.$result->getMessage()); foreach ($result as $message) {
} elseif ($result) { if (false !== strpos($message, '<error>')) {
if (is_array($result)) { $hadError = true;
foreach ($result as $message) {
$io->write($message);
}
} else {
$io->write($result);
} }
} }
} }
if ($hadError) {
$io->write('<error>FAIL</error>');
$this->exitCode = 2;
} else {
$io->write('<warning>WARNING</warning>');
$this->exitCode = 1;
}
if ($result) {
foreach ($result as $message) {
$io->write($message);
}
}
} }
private function checkPlatform() private function checkPlatform()

Loading…
Cancel
Save