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

Return value of CompositeRepository::findPackage() have changed in 2.3.0 #10622

Closed
boesing opened this issue Mar 16, 2022 · 2 comments
Closed
Labels
Milestone

Comments

@boesing
Copy link
Contributor

boesing commented Mar 16, 2022

Hey there,

I've quickly checked out composer v2.3.0 and ended up in an fatal error when working with a composer plugin which uses the CompositeRepository to find a package by its name.

I doubt that it is plugin related as we do not have any influence on what is actually returned from that composite repository.

Here is the related code which leads to the fatal error

https://github.com/laminas/laminas-component-installer/blob/4a882e650d8a280b2f33b65b493e25d9e0bccbd3/src/PackageProvider/PackageProviderDetectionFactory.php#L52

The fatal error

PHP Fatal error:  Uncaught TypeError: Return value of Composer\Repository\CompositeRepository::findPackage() must be an instance of Composer\Package\BasePackage or null, bool returned in phar:///Users/max/.bin/composer/src/Composer/Repository/CompositeRepository.php:84
Stack trace:
#0 /project/vendor/laminas/laminas-component-installer/src/PackageProvider/PackageProviderDetectionFactory.php(69): Composer\Repository\CompositeRepository->findPackage('mobilfunk-hardw...', '*')
#1 /project/vendor/laminas/laminas-component-installer/src/ComponentInstaller.php(228): Laminas\ComponentInstaller\PackageProvider\PackageProviderDetectionFactory->detect(Object(Composer\Installer\PackageEvent), 'mobilfunk-hardw...')
#2 [internal function]: Laminas\ComponentInstaller\ComponentInstaller->onPostPackageInstall(Object(Composer\Installer\PackageEvent))
#3 phar:///Users/max/.bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(199): call_user_func(Array, Object(Composer\Installer\PackageEve in phar:///Users/max/.bin/composer/src/Composer/Repository/CompositeRepository.php on line 84

Happy to be of help if you need further details.

@boesing
Copy link
Contributor Author

boesing commented Mar 16, 2022

I was able to track it down to:

return reset($packages['packages']);

@Seldaek
Copy link
Member

Seldaek commented Mar 16, 2022

Thanks for pinpointing it, easy fix :)

emahorvat52 pushed a commit to emahorvat52/composer that referenced this issue Feb 3, 2023
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