Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: ComposerRepository::loadRootServerFile condition "null !== $this->rootData" will/may throw to TypeError #10675

Closed
Fahl-Design opened this issue Mar 30, 2022 · 2 comments
Labels
Milestone

Comments

@Fahl-Design
Copy link

@Fahl-Design Fahl-Design commented Mar 30, 2022

Hi, I got a TypeError when running composer update on a project:

Infos

Versions:

  • 2.3.1
  • 2.3-dev (2.3-dev+c3484ea882d457422dcb94de539052359e997a52) 2022-03-30 14:34:59

Bug

....
    /** @var mixed[]|true */
    private $rootData;
....
    /**
     * @param int|null $rootMaxAge
     * @return array<string, mixed>
     */
    protected function loadRootServerFile(?int $rootMaxAge = null): array
    {
        if (null !== $this->rootData) {
            return $this->rootData; // <-- MAY BE BOOL
        }

https://github.com/composer/composer/blob/main/src/Composer/Repository/ComposerRepository.php#L1018:L1022

Error Trace

In ComposerRepository.php line 1021:
                                                                                                                   
  [TypeError]                                                                                                      
  Composer\Repository\ComposerRepository::loadRootServerFile(): Return value must be of type array, bool returned  
                                                                                                                   

Exception trace:
  at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:1021
 Composer\Repository\ComposerRepository->loadRootServerFile() at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:684
 Composer\Repository\ComposerRepository->hasProviders() at phar:///usr/bin/composer/src/Composer/Repository/ComposerRepository.php:471
 Composer\Repository\ComposerRepository->loadPackages() at phar:///usr/bin/composer/src/Composer/Repository/FilterRepository.php:127
 Composer\Repository\FilterRepository->loadPackages() at phar:///usr/bin/composer/src/Composer/DependencyResolver/PoolBuilder.php:381
 Composer\DependencyResolver\PoolBuilder->loadPackagesMarkedForLoading() at phar:///usr/bin/composer/src/Composer/DependencyResolver/PoolBuilder.php:234
 Composer\DependencyResolver\PoolBuilder->buildPool() at phar:///usr/bin/composer/src/Composer/Repository/RepositorySet.php:260
 Composer\Repository\RepositorySet->createPool() at phar:///usr/bin/composer/src/Composer/Installer.php:436
 Composer\Installer->doUpdate() at phar:///usr/bin/composer/src/Composer/Installer.php:279
 Composer\Installer->run() at phar:///usr/bin/composer/src/Composer/Command/UpdateCommand.php:241
 Composer\Command\UpdateCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:1015
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:334
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:130
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:83
 require() at /usr/bin/composer:30
@Seldaek Seldaek added this to the 2.3 milestone Mar 30, 2022
@Seldaek Seldaek added the Bug label Mar 30, 2022
@Fahl-Design
Copy link
Author

@Fahl-Design Fahl-Design commented Mar 30, 2022

@Seldaek thank you!

@Seldaek
Copy link
Member

@Seldaek Seldaek commented Mar 30, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants