1
0
Fork 0

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.
pull/8993/head
johnstevenson 2020-02-28 16:15:34 +00:00 committed by Jordi Boggiano
parent a17bbec842
commit 54debe8210
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 11 additions and 2 deletions

View File

@ -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>';

View File

@ -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) {