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

Declaration of AbstractLogger::emergency must be compatible with #517

Closed
markus-rothenbacher-tech opened this issue Feb 18, 2023 · 4 comments · Fixed by #578 · May be fixed by #520
Closed

Declaration of AbstractLogger::emergency must be compatible with #517

markus-rothenbacher-tech opened this issue Feb 18, 2023 · 4 comments · Fixed by #578 · May be fixed by #520

Comments

@markus-rothenbacher-tech
Copy link

markus-rothenbacher-tech commented Feb 18, 2023

Steps to reproduce

  1. install Nextcloud 25.0.3 with PHP 8.1
  2. install sentry plugin
  3. set my sentry sentry in config.php
  4. refresh my nextcloud page in the browser
  5. broken 500 screen
  6. if I comment out the sentry entries in the config.php my nextcloud installation works normal again

Expected behaviour

Nextcloud should keep running and submit errors to my sentry installation

Actual behaviour

  • Website shows 500 Server Error.
  • as I have a PHP experience my research concluded, that my nextcloud instance uses an old Version of PSR, which is not compatible to the one you use in the sentry plugin. But as I have no knowledge of the nextcloud architecture I could not go further into the debugging

Server configuration

Operating system: Ubuntu 22.04 (kubernetes docker)

Web server: Apache/2.4.52

Database: bitnami/mariadb:10.6.12-debian-11-r3

PHP version: PHP 8.1.16

Version: Nextcloud 25.0.3

Updated from an older version or fresh install: fresh install

List of activated apps:

  - activity: 2.17.0
  - calendar: 4.2.3
  - circles: 25.0.0
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - contacts: 5.1.0
  - contactsinteraction: 1.6.0
  - dashboard: 7.5.0
  - dav: 1.24.0
  - deck: 1.8.3
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - firstrunwizard: 2.14.0
  - groupfolders: 13.1.1
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - mail: 2.2.3
  - nextcloud_announcements: 1.14.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - password_policy: 1.15.0
  - photos: 2.0.1
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - recognize: 3.5.0
  - recommendations: 1.4.0
  - related_resources: 1.0.3
  - sentry: 8.6.4
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - spreed: 15.0.3
  - support: 1.8.0
  - survey_client: 1.13.0
  - systemtags: 1.15.0
  - text: 3.6.0
  - theming: 2.0.1
  - twofactor_backupcodes: 1.14.0
  - updatenotification: 1.15.0
  - user_status: 1.5.0
  - viewer: 1.9.0
  - weather_status: 1.5.0
  - workflowengine: 2.7.0
Disabled:
  - admin_audit
  - bruteforcesettings
  - encryption
  - files_external
  - richdocuments: 7.1.1
  - suspicious_login
  - twofactor_totp
  - user_ldap

The content of config/config.php:

$CONFIG = array (
  'instanceid' => 'xxxxxxxxxxxxxxxxx',
  'passwordsalt' => 'yyyyyyyyyyyyyyyyyy',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.server.my',
  ),
  'trusted_proxies' => 
  array (
    0 => '10.188.5.1',
  ),
  'htaccess.RewriteBase' => '/',
  'overwritehost' => 'nextcloud.server.my',
  'overwriteprotocol' => 'https',
  'datadirectory' => '/data',
  'dbtype' => 'mysql',
  'version' => '25.0.3.2',
  'overwrite.cli.url' => 'https://nextcloud.server.my',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxxxxxxxxxxxxxxxxxxx',
  'installed' => true,
  'default_phone_region' => 'DE',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'nextcloud-redis-master',
    'port' => 6379,
    'password' => 'xxxxxxxxxxxxxxxxxxxx',
  ),
  'sentry.dsn' => 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxx:[email protected]/4',
  'sentry.public-dsn' => 'https://[email protected]/4',
);

Client configuration

  • any client any browser

Logs

Web server error log
[Sat Feb 18 22:11:29.338850 2023] [php:error] [pid 745] [client 10.42.0.10:55886] PHP Fatal error: Declaration of Psr\\Log\\AbstractLogger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\\Log\\LoggerInterface::emergency($message, array $context = []) in /var/www/project/public/apps/sentry/vendor/psr/log/src/LoggerTrait.php on line 23
Server log (data/nextcloud.log)
{
  "reqId": "iivsgGX1sn6zMSERyXXX",
  "level": 3,
  "time": "2023-02-18T22:00:01+00:00",
  "remoteAddr": "10.42.0.10",
  "user": "--",
  "app": "PHP",
  "method": "GET",
  "url": "/cron.php",
  "message": "Declaration of Psr\\Log\\AbstractLogger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\\Log\\LoggerInterface::emergency($message, array $context = []) at /var/www/project/public/apps/sentry/vendor/psr/log/src/LoggerTrait.php#23",
  "userAgent": "curl/7.74.0",
  "version": "25.0.3.2",
  "data": {
    "app": "PHP"
  }
}
Browser log
Browser shows Server 500 error
@ChristophWurst
Copy link
Owner

Either Nextcloud or another app ships the psr/log package as well, but in an incompatible version. We need to find out where this is coming from. This app ships a resent version of psr/log and I have the suspicion that another app ships an old one.

Search your Nextcloud installation for a psr/log/src/LoggerInterface.php file. E.g.

$ find . -name LoggerInterface.php -path "*psr/log/src*"
./vendor-bin/psalm/vendor/psr/log/src/LoggerInterface.php
./apps/mail/vendor-bin/rector/vendor/rector/rector/vendor/psr/log/src/LoggerInterface.php
./apps/sentry/vendor/psr/log/src/LoggerInterface.php
./apps/spreed/vendor-bin/csfixer/vendor/psr/log/src/LoggerInterface.php
./apps/spreed/vendor-bin/psalm/vendor/psr/log/src/LoggerInterface.php
./apps/twofactor_webauthn/vendor-bin/cs-fixer/vendor/psr/log/src/LoggerInterface.php
./apps/calendar/vendor-bin/cs-fixer/vendor/psr/log/src/LoggerInterface.php

@ChristophWurst
Copy link
Owner

See #520. I attached a tarball for testing.

@markus-rothenbacher-tech
Copy link
Author

markus-rothenbacher-tech commented Feb 20, 2023

Herre my result:

find . -name LoggerInterface.php -path "*psr/log/src*"
./apps/sentry/vendor/psr/log/src/LoggerInterface.php

So the exact pattern is only found in the sentry plugin.

But if I search like this I find more files:

find . -name LoggerInterface.php
./3rdparty/psr/log/Psr/Log/LoggerInterface.php
./3rdparty/scssphp/scssphp/src/Logger/LoggerInterface.php
./apps/suspicious_login/vendor/psr/log/Psr/Log/LoggerInterface.php
./apps/mail/vendor/psr/log/Psr/Log/LoggerInterface.php
./apps/recognize/vendor/psr/log/Psr/Log/LoggerInterface.php
./apps/sentry/vendor/psr/log/src/LoggerInterface.php

of those, here are the ones of these files which contain the outdated version of the emergency function definition without the : void return parameter:

./3rdparty/psr/log/Psr/Log/LoggerInterface.php:    public function emergency($message, array $context = array());
./apps/suspicious_login/vendor/psr/log/Psr/Log/LoggerInterface.php:    public function emergency($message, array $context = array());
./apps/mail/vendor/psr/log/Psr/Log/LoggerInterface.php:    public function emergency($message, array $context = array());
./apps/recognize/vendor/psr/log/Psr/Log/LoggerInterface.php:    public function emergency($message, array $context = array());

FYI: I have a basic vanilla installation from extracting the install file. You can find for example the outdated "./3rdparty/psr/log/Psr/Log/LoggerInterface.php" in the latest server download file: https://download.nextcloud.com/server/releases/latest.tar.bz2

@skjnldsv
Copy link

skjnldsv commented May 7, 2023

Break 26 for me as well

{
  "reqId": "JcVcxCXNwyRte9gi9Im9",
  "level": 3,
  "time": "2023-05-07T11:17:14+00:00",
  "remoteAddr": "xxx.xxx.xxx.xxx",
  "user": "skjnldsv",
  "app": "PHP",
  "method": "GET",
  "url": "/index.phpapps/disabled/suspicious_login",
  "message": "Declaration of Psr\\Log\\AbstractLogger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\\Log\\LoggerInterface::emergency($message, array $context = []) at /var/www/html/custom_apps/sentry/vendor/psr/log/src/LoggerTrait.php#23",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
  "version": "26.0.1.1",
  "data": {
    "app": "PHP"
  }
}

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