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

PHP Fatal error: Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus #341

Open
3038922 opened this issue Dec 12, 2023 · 13 comments

Comments

@3038922
Copy link

3038922 commented Dec 12, 2023

ubuntu 22.04.
php 8.1
elasticsearch 8.6.1

 ⚡ root@nextcloud  ~  sudo -u www-data php /var/www/nextcloud/occ  fulltextsearch:test

.Testing your current setup:
Creating mocked content provider. ok
Testing mocked provider: get indexable documents. (2 items) ok
Loading search platform. (Elasticsearch) ok
Testing search platform. PHP Fatal error:  Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string $reasonPhrase = ''): Psr\Http\Message\ResponseInterface must be compatible with Psr\Http\Message\ResponseInterface::withStatus($code, $reasonPhrase = '') in /var/www/nextcloud/apps/fulltextsearch_elasticsearch/vendor/elasticsearch/elasticsearch/src/Traits/MessageResponseTrait.php on line 87
 ⚡ root@nextcloud  ~  sudo -u www-data php --ini
Configuration File (php.ini) Path: /etc/php/8.1/cli
Loaded Configuration File:         /etc/php/8.1/cli/php.ini
Scan for additional .ini files in: /etc/php/8.1/cli/conf.d
Additional .ini files parsed:      /etc/php/8.1/cli/conf.d/10-mysqlnd.ini,
/etc/php/8.1/cli/conf.d/10-opcache.ini,
/etc/php/8.1/cli/conf.d/10-pdo.ini,
/etc/php/8.1/cli/conf.d/15-xml.ini,
/etc/php/8.1/cli/conf.d/20-apcu.ini,
/etc/php/8.1/cli/conf.d/20-bcmath.ini,
/etc/php/8.1/cli/conf.d/20-bz2.ini,
/etc/php/8.1/cli/conf.d/20-calendar.ini,
/etc/php/8.1/cli/conf.d/20-ctype.ini,
/etc/php/8.1/cli/conf.d/20-curl.ini,
/etc/php/8.1/cli/conf.d/20-dom.ini,
/etc/php/8.1/cli/conf.d/20-exif.ini,
/etc/php/8.1/cli/conf.d/20-ffi.ini,
/etc/php/8.1/cli/conf.d/20-fileinfo.ini,
/etc/php/8.1/cli/conf.d/20-ftp.ini,
/etc/php/8.1/cli/conf.d/20-gd.ini,
/etc/php/8.1/cli/conf.d/20-gettext.ini,
/etc/php/8.1/cli/conf.d/20-gmp.ini,
/etc/php/8.1/cli/conf.d/20-iconv.ini,
/etc/php/8.1/cli/conf.d/20-igbinary.ini,
/etc/php/8.1/cli/conf.d/20-imagick.ini,
/etc/php/8.1/cli/conf.d/20-intl.ini,
/etc/php/8.1/cli/conf.d/20-ldap.ini,
/etc/php/8.1/cli/conf.d/20-mbstring.ini,
/etc/php/8.1/cli/conf.d/20-mysqli.ini,
/etc/php/8.1/cli/conf.d/20-pdo_mysql.ini,
/etc/php/8.1/cli/conf.d/20-phar.ini,
/etc/php/8.1/cli/conf.d/20-posix.ini,
/etc/php/8.1/cli/conf.d/20-readline.ini,
/etc/php/8.1/cli/conf.d/20-redis.ini,
/etc/php/8.1/cli/conf.d/20-shmop.ini,
/etc/php/8.1/cli/conf.d/20-simplexml.ini,
/etc/php/8.1/cli/conf.d/20-sockets.ini,
/etc/php/8.1/cli/conf.d/20-sysvmsg.ini,
/etc/php/8.1/cli/conf.d/20-sysvsem.ini,
/etc/php/8.1/cli/conf.d/20-sysvshm.ini,
/etc/php/8.1/cli/conf.d/20-tokenizer.ini,
/etc/php/8.1/cli/conf.d/20-xmlreader.ini,
/etc/php/8.1/cli/conf.d/20-xmlrpc.ini,
/etc/php/8.1/cli/conf.d/20-xmlwriter.ini,
/etc/php/8.1/cli/conf.d/20-xsl.ini,
/etc/php/8.1/cli/conf.d/20-zip.ini
@timdodge
Copy link

Seems to be this issue: elastic/elasticsearch-php#1342

@jstampfer
Copy link

jstampfer commented Dec 25, 2023

Same here, but I have no idea how to fix it with this: elastic/elasticsearch-php#1342

Testing search platform. PHP Fatal error: Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string $reasonPhrase = ''): Psr\Http\Message\ResponseInterface must be compatible with Psr\Http\Message\ResponseInterface::withStatus($code, $reasonPhrase = '') in /var/www/nextcloud/apps/fulltextsearch_elasticsearch/vendor/elasticsearch/elasticsearch/src/Traits/MessageResponseTrait.php on line 87

I get this error:

┌─ Errors ────
│ Error: 1642/1642
│ Index: files:315863
│ Exception: Elastic\Elasticsearch\Exception\ServerResponseException
│ Message: unknown error

@edgeofthex
Copy link

I get the same error message when I run sudo -u www-data php /var/www/nextcloud/occ fulltextsearch:test. I wonder if this indexing app is working for anybody, or is it just a few people running into problems?

@aakerbeere
Copy link

My instance is actually not throwing errors. I'm however not sure if it is doing the job as expected. Don't know how to test otherwise:

.Testing your current setup:  
Creating mocked content provider. ok  
Testing mocked provider: get indexable documents. (2 items) ok  
Loading search platform. (Elasticsearch) ok  
Testing search platform. ok  
Locking process ok  
Removing test. ok  
Pausing 3 seconds 1 2 3 ok  
Initializing index mapping. ok  
Indexing generated documents. ok  
Pausing 3 seconds 1 2 3 ok  
Retreiving content from a big index (license). (size: 32386) ok  
Comparing document with source. ok  
Searching basic keywords:  
 - 'test' (result: 1, expected: ["simple"]) ok  
 - 'document is a simple test' (result: 2, expected: ["simple","license"]) ok  
 - '"document is a test"' (result: 0, expected: []) ok  
 - '"document is a simple test"' (result: 1, expected: ["simple"]) ok  
 - 'document is a simple -test' (result: 1, expected: ["license"]) ok  
 - 'document is a simple +test' (result: 1, expected: ["simple"]) ok  
 - '-document is a simple test' (result: 0, expected: []) ok  
 - 'document is a simple +test +testing' (result: 1, expected: ["simple"]) ok  
 - 'document is a simple +test -testing' (result: 0, expected: []) ok  
 - 'document is a +simple -test -testing' (result: 0, expected: []) ok  
 - '+document is a simple -test -testing' (result: 1, expected: ["license"]) ok  
 - 'document is a +simple -license +testing' (result: 1, expected: ["simple"]) ok  
Updating documents access. Force Quit

Instance:

Rasperry Pi 4 Model B Rev 1.4 8GB
Debian GNU/linux 12 (bookworm)
NC "27.1.5.1"
Webserver "Apache/2.4.57 (Debian)"
PHP "8.2.14"
DB "PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit"
Full text search - Elasticsearch Platform 27.0.5
Full text search 27.0.3
Full text search - Files 27.0.1
Full text search - Files - Tesseract OCR 27.0.0
elasticsearch/stable,now 8.11.3 arm64 with readonlyrest

cheers

@bt1v1
Copy link

bt1v1 commented Dec 30, 2023

I get the same error with nextcloud 28. All plugins have also been updated to version >28.

@edgeofthex
Copy link

I get the same error with nextcloud 28. All plugins have also been updated to version >28.

I'm on 28 as well.

@jstampfer
Copy link

If I make "sudo -u www-data php occ fulltextsearch:test" then I get the following errors:

.Testing your current setup:
Creating mocked content provider. ok
Testing mocked provider: get indexable documents. (2 items) ok
Loading search platform. (Elasticsearch) ok
Testing search platform. PHP Fatal error: Declaration of Elastic\Elasticsearch\Response\Elasticsearch::withStatus(int $code, string $reasonPhrase = ''): Psr\Http\Message\ResponseInterface must be compatible with Psr\Http\Message\ResponseInterface::withStatus($code, $reasonPhrase = '') in /var/www/nextcloud/apps/fulltextsearch_elasticsearch/vendor/elasticsearch/elasticsearch/src/Traits/MessageResponseTrait.php on line 87

Nextcloud version: 28.0.1 all updates installed

PHP-Version: 8.1.27

Elasticsearch: 8.11.3

I run the following Ubuntu:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal

@SanMichele
Copy link

Hello,
I'm on NC28 and ES 8.12.1, same error.
Is it an Elastic error or a Nextcloud error? Who is responsible to solve it?
THX, Michael

@random6150
Copy link

I installed NC28 and ES 8.12 and hit the same error.

I'm not a coder but I followed up the error message and it seems working by making some changes to /var/www/nextcloud/apps/fulltextsearch_elasticsearch/vendor/elasticsearch/elasticsearch/src/Traits/MessageResponseTrait.php
in lines 42, 57, 62, 67, and 87.

I have no idea how to show changes in the reply, please see the attached file.
MessageResponseTrait.zip

After applying the changes, the fulltextsearch seems working. It ignores one of my external local storage folders however, this may be another issue.

Wish you guys good luck.

@SanMichele
Copy link

Hi,
found it: With the app Carnet also comes ./apps/carnet/vendor/psr/http-message/src/ResponseInterface.php with the wrong declaration. Delete Carnet and the error is gone.
Kind regards, Michael

@s90570
Copy link

s90570 commented Feb 29, 2024

Hi, found it: With the app Carnet also comes ./apps/carnet/vendor/psr/http-message/src/ResponseInterface.php with the wrong declaration. Delete Carnet and the error is gone. Kind regards, Michael

Incomprehensible. Yes. It was enough to turn off the Carnet. But what is the problem? Carnet or Elasticsearch?

@random6150
Copy link

random6150 commented Feb 29, 2024 via email

@s90570
Copy link

s90570 commented Feb 29, 2024

I guess the problem was caused by Carnet. I removed Carnet and reinstalled elasticsearch without any modification, everything works well. From my previous modification, this might because Carnet incorporated and old version of psr components, which loaded first.

Exactly! I renamed /nextcloud/apps/carnet/vendor/psr/http-message to /nextcloud/apps/carnet/vendor/psr/http-messageOLD and made a symlink to /nextcloud/apps/fulltextsearch_elasticsearch/vendor/psr/http-message.
Carnet still uses psr/http-message version 1.x while elasticsearch uses version 2.0 already.

And it seems to be working. Many thanks gentlemen!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants