1
0
Fork 0

Ensure diagnose command works even if provider-includes disappears

pull/11943/head
Jordi Boggiano 2024-04-19 14:20:56 +02:00
parent 41fb6146b0
commit 3604996464
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 8 additions and 6 deletions

View File

@ -328,13 +328,15 @@ EOT
} }
$json = $this->httpDownloader->get($protocol.'://repo.packagist.org/packages.json')->decodeJson(); $json = $this->httpDownloader->get($protocol.'://repo.packagist.org/packages.json')->decodeJson();
$hash = reset($json['provider-includes']); if (isset($json['provider-includes'])) {
$hash = $hash['sha256']; $hash = reset($json['provider-includes']);
$path = str_replace('%hash%', $hash, key($json['provider-includes'])); $hash = $hash['sha256'];
$provider = $this->httpDownloader->get($protocol.'://repo.packagist.org/'.$path)->getBody(); $path = str_replace('%hash%', $hash, key($json['provider-includes']));
$provider = $this->httpDownloader->get($protocol.'://repo.packagist.org/'.$path)->getBody();
if (hash('sha256', $provider) !== $hash) { if (hash('sha256', $provider) !== $hash) {
return '<warning>It seems that your proxy ('.$proxyStatus.') is modifying '.$protocol.' traffic on the fly</>'; return '<warning>It seems that your proxy ('.$proxyStatus.') is modifying '.$protocol.' traffic on the fly</>';
}
} }
return '<info>OK</> <comment>'.$proxyStatus.'</>'; return '<info>OK</> <comment>'.$proxyStatus.'</>';