algolia / algoliasearch-client-php

⚡️ A fully-featured and blazing-fast PHP API client to interact with Algolia.
https://www.algolia.com/doc/api-client/php/getting-started/
MIT License
671 stars 116 forks source link

UriInterface error after composer update #720

Closed pgbrown closed 11 months ago

pgbrown commented 1 year ago

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

damcou commented 1 year ago

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.

pgbrown commented 1 year ago

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

damcou commented 1 year ago

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:

Thanks again.

pgbrown commented 1 year ago

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

damcou commented 1 year ago

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 ?

pgbrown commented 1 year ago

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?

nlighteneddesign commented 1 year ago

I had this issue too, pinning to "algolia/algoliasearch-client-php": "3.3.2", fixed the issue for me as well.

damcou commented 1 year ago

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. 🙌

Nicolas-Bouteille commented 1 year ago

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!

pgbrown commented 1 year ago

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