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)

Created on 5 September 2023, 10 months ago
Updated 29 January 2024, 5 months ago

Problem/Motivation

Hi, I encounter the following error when I create a search server, view the server, or view the index:

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 /var/www/html/vendor/algolia/algoliasearch-client-php/src/Http/Psr7/Uri.php on line 439

Steps to reproduce

1. Composer install the latest beta version
2. Create a server (shows error, but server created correctly)
3. View the server (shows error)
4. Create an index (shows error, but index created)
5. View the index (shows error)

I tried to downgrade algoliasearch-client-php to 3.3.x but it doesn't seem to work. My Drupal version is 9.5.10.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

User interface

Created by

πŸ‡―πŸ‡΅Japan hktang

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @hktang
  • πŸ‡ΊπŸ‡ΈUnited States josh.stewart Lexington, KY

    Confirming I'm running into this issue as well.

  • πŸ‡ΊπŸ‡ΈUnited States josh.stewart Lexington, KY

    I downgraded to algolia/algoliasearch-client-php:3.3.2 to resolve the issue. The implementation of typing is not lining up with the UriInterface declaration. I'm okay to do this for now. Doesn't seem like a problem for this module, but moreso with the UriInterface.

  • πŸ‡ΊπŸ‡ΈUnited States millerrs

    I bumped into the same problem (Drupal 9.5.10/PHP 8.1). Just like josh.stewart, switching to 3.3.x sorted it out for me. Here's how I did it: composer require algolia/algoliasearch-client-php:~3.3.2

    The culprit behind the need to roll back is the psr/http-message dependency. From what I can tell, Drupal 9.5x blocks updating to a version that would fix this.

  • πŸ‡¬πŸ‡§United Kingdom hdotnet

    Same here, but in cron, downgrading the algolia search client to 3.3.2 fixes it

    [INFO] [cron] [2023-09-07T10:32:56] Starting execution of search_api_cron(), execution of purge_processor_cron_cron() took 39.31ms. | uid: 0 | request-uri: http://default/ | refer:  | ip:  127.0.0.1 | link: 
    PHP 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 /var/www/vendor/algolia/algoliasearch-client-php/src/Http/Psr7/Uri.php on line 439
     [warning] Drush command terminated abnormally.
    
  • πŸ‡¦πŸ‡ΉAustria kevin.pfeifer

    We just updated algolia/algoliasearch-client-php from 3.3.2 to 3.4.0 and this error appears.

  • πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

    Yeah the error is caused by an update to the client to v3.4, which according to https://github.com/algolia/algoliasearch-client-php/issues/720 is not an official or supported release yet. This might require a more specific version constraint in this module to prevent the error.

  • πŸ‡§πŸ‡ͺBelgium DieterHolvoet Brussels

    This fixed the issue for me, without needing to lock a specific version of algolia/algoliasearch-client-php:

    • composer remove drupal/core-recommended (make sure drupal/core is installed instead)
    • composer update algolia/algoliasearch-client-php psr/http-message

    Looks like this issue is only present in Drupal 9: drupal/core-recommended:9.5.11 has a dependency on psr/http-message:~1.0.1, Drupal 10 does not have a dependency on psr/http-message.

    The best solution to me seems to add a conflict on algolia/algoliasearch-client-php:>3.3.2 to composer.json, and to remove it again once a release of this module comes out that drops support for Drupal 9.

  • Merge request !18Add conflict β†’ (Open) created by DieterHolvoet
  • Status changed to Needs review 5 months ago
  • πŸ‡§πŸ‡ͺBelgium DieterHolvoet Brussels
Production build 0.69.0 2024