Skip to content

Commit

Permalink
Fix handling of true return value for loadRootServerFile, fixes compo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and emahorvat52 committed Jan 18, 2023
1 parent 488ccd1 commit 43ebcb5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Composer/Repository/ComposerRepository.php
Expand Up @@ -657,7 +657,10 @@ private function getProviderNames(): array
$this->loadRootServerFile();

if (null === $this->providerListing) {
$this->loadProviderListings($this->loadRootServerFile());
$data = $this->loadRootServerFile();
if (is_array($data)) {
$this->loadProviderListings($data);
}
}

if ($this->lazyProvidersUrl) {
Expand Down Expand Up @@ -713,7 +716,10 @@ private function whatProvides(string $name, array $acceptableStabilities = null,
}

if (null === $this->providerListing) {
$this->loadProviderListings($this->loadRootServerFile());
$data = $this->loadRootServerFile();
if (is_array($data)) {
$this->loadProviderListings($data);
}
}

$useLastModifiedCheck = false;
Expand Down Expand Up @@ -1020,9 +1026,9 @@ private function getPackagesJsonUrl(): string

/**
* @param int|null $rootMaxAge
* @return array<string, mixed>
* @return array<'providers'|'provider-includes'|'packages'|'providers-url'|'notify-batch'|'search'|'mirrors'|'providers-lazy-url'|'metadata-url'|'available-packages'|'available-package-patterns', mixed>|true
*/
protected function loadRootServerFile(?int $rootMaxAge = null): array
protected function loadRootServerFile(?int $rootMaxAge = null)
{
if (null !== $this->rootData) {
return $this->rootData;
Expand Down Expand Up @@ -1163,6 +1169,9 @@ private function canonicalizeUrl(string $url): string
private function loadDataFromServer(): array
{
$data = $this->loadRootServerFile();
if (true === $data) {
throw new \LogicException('loadRootServerFile should not return true during initialization');
}

return $this->loadIncludes($data);
}
Expand Down Expand Up @@ -1579,6 +1588,9 @@ private function asyncFetchFile(string $filename, string $cacheKey, ?string $las
private function initializePartialPackages(): void
{
$rootData = $this->loadRootServerFile();
if ($rootData === true) {
return;
}

$this->partialPackagesByName = array();
foreach ($rootData['packages'] as $package => $versions) {
Expand Down

0 comments on commit 43ebcb5

Please sign in to comment.