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, about 1 year 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

Active

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 10 months ago
  • 🇮🇳India nikunjkotecha India, Gujarat, Rajkot

    Will create 4.x for git clone git@git.drupal.org:project/mobile_app_links.git
    Will merge this in 3.x

  • Status changed to Closed: won't fix about 2 months ago
  • 🇮🇳India nikunjkotecha India, Gujarat, Rajkot

    Wrong project in previous comment
    Considering workaround is possible in 9.x as explained in https://www.drupal.org/project/search_api_algolia/issues/3381297 🐛 Algolia Library Version Active and 9.x is no longer supported I am inclined towards not doing any fix for this.

Production build 0.71.5 2024