UriInterface error after composer update
- Algolia Client Version: v3.4.0
- Language Version: PHP v7.3.27
Description
I ran composer update today and the Algolia Client was upgraded from v3.3.2 to v3.4.0. This resulted in the following error:
Fatal error: Declaration of Algolia\AlgoliaSearch\Http\Psr7\Uri::withScheme(string $scheme): Psr\Http\Message\UriInterface must be compatible with Psr\Http\Message\UriInterface::withScheme($scheme) in /disguising-path-to-directory-here/vendor/algolia/algoliasearch-client-php/src/Http/Psr7/Uri.php](http://disguising-domain-name-here/html/vendor/algolia/algoliasearch-client-php/src/Http/Psr7/Uri.php) on line 18
So I rolled back to Algolia Client v3.3.2 and everything is fine again.
Steps To Reproduce
Ran composer update on PHP v7.3.27
Hello @pgbrown and thanks a lot for raising this issue.
Could you tell me if the psr/http-message dependency remains on v1 after the update ?
Also, are you using a Guzzle Http client in your project ?
Thanks again.
Hi
Yes psr/http-message is there before and after the update, in the composer.lock file.
Yes Guzzle HTTP client is used in this project.
Thanks
Thanks for your quick answer. We'll review this asap and release a new version if needed.
Could you the version of your dependencies in your composer.json file so we can try to reproduce the issue on our end, regarding:
- php
- algoliasearch/algolia-client-php
- guzzlehttp/guzzle
- psr/http-message
Thanks again.
When I recreate the bug in our dev environment and run composer show -l, the versions are:
php v7.3.1
algolia/algoliasearch-client-php v.4.0
guzzlehttp/guzzle v6.5.8
psr/http-message v1.01
Thanks
Thanks for the information, apparently your composer switches to v4.0 which is a branch where we are currently developing the new client which should be available soon and not released yet. Could you try to update with staying en v3 to see how it goes please ?
I have already locked it to 3.3.2 like so and it has been working fine
"algolia/algoliasearch-client-php": "3.3.2"
Previously it was set like this and when I did a composer update it upgraded to 3.4.0
"algolia/algoliasearch-client-php": "^3.3"
Is that what you are talking about?
I had this issue too, pinning to "algolia/algoliasearch-client-php": "3.3.2", fixed the issue for me as well.
Hello @pgbrown and @nlighteneddesign , I just released the v3.4.1 which includes the change mentioned here: https://github.com/algolia/algoliasearch-client-php/pull/719#issuecomment-1693416696 .
Would it be possible for you to give it a try ? Thanks in advance. 🙌
Hello, I was facing the exact same problem. At first I could not install v3.4.1 which requires psr/http-message^1.1, because drupal-core-recommended requires psr/http-message~1.0.1 I forked drupal-core-recommended so that I could force install psr/http-message 1.1 and after installing v3.4.1 the errors are gone. I was lucky you just released the fix the day before I had to work on that! Thank you!
Hi
Like @Nicolas-Bouteille, I had to fix up another package that had a dependency on psr/http-message v1. But once I fixed that Algolia upgraded to v3.4.1 with no errors on the web site.
Thanks