Respect disable-tls in Versions::getLatest

Use http to get the latest version when disable-tls is true and error-
trap DiagnoseCommand::checkVersion so that all checks can complete.
Fixes #8657.
main
johnstevenson 4 years ago committed by Jordi Boggiano
parent a17bbec842
commit 54debe8210
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -432,7 +432,11 @@ EOT
}
$versionsUtil = new Versions($config, $this->rfs);
$latest = $versionsUtil->getLatest();
try {
$latest = $versionsUtil->getLatest();
} catch (\Exception $e) {
return $e;
}
if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';

@ -63,7 +63,12 @@ class Versions
public function getLatest($channel = null)
{
$protocol = extension_loaded('openssl') ? 'https' : 'http';
if ($this->config->get('disable-tls') === true) {
$protocol = 'http';
} else {
$protocol = 'https';
}
$versions = JsonFile::parseJson($this->rfs->getContents('getcomposer.org', $protocol . '://getcomposer.org/versions', false));
foreach ($versions[$channel ?: $this->getChannel()] as $version) {

Loading…
Cancel
Save