From 3604996464d9a2e3df8b77867f502d2ecb50bf2e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 19 Apr 2024 14:20:56 +0200 Subject: [PATCH] Ensure diagnose command works even if provider-includes disappears --- src/Composer/Command/DiagnoseCommand.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index d06031076..28a38282a 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -328,13 +328,15 @@ EOT } $json = $this->httpDownloader->get($protocol.'://repo.packagist.org/packages.json')->decodeJson(); - $hash = reset($json['provider-includes']); - $hash = $hash['sha256']; - $path = str_replace('%hash%', $hash, key($json['provider-includes'])); - $provider = $this->httpDownloader->get($protocol.'://repo.packagist.org/'.$path)->getBody(); + if (isset($json['provider-includes'])) { + $hash = reset($json['provider-includes']); + $hash = $hash['sha256']; + $path = str_replace('%hash%', $hash, key($json['provider-includes'])); + $provider = $this->httpDownloader->get($protocol.'://repo.packagist.org/'.$path)->getBody(); - if (hash('sha256', $provider) !== $hash) { - return 'It seems that your proxy ('.$proxyStatus.') is modifying '.$protocol.' traffic on the fly'; + if (hash('sha256', $provider) !== $hash) { + return 'It seems that your proxy ('.$proxyStatus.') is modifying '.$protocol.' traffic on the fly'; + } } return 'OK '.$proxyStatus.'';