matomo-for-wordpress icon indicating copy to clipboard operation
matomo-for-wordpress copied to clipboard

Declaration of DI\\Container::has($name) must be compatible with Psr\\Container\\ContainerInterface::has(string $id): bool

Open 411x opened this issue 2 years ago • 2 comments

Hello, I got this error with the version 4.11.0. It was working a month ago. Maybe a plugin or wordpress was updated. No change on the environment.

PHP Fatal error: Declaration of DI\\Container::has($name) must be compatible with Psr\\Container\\ContainerInterface::has(string $id): bool in /data/web/wp-content/plugins/matomo/app/vendor/php-di/php-di/src/Container.php on line 210',

# Matomo

* Version de l’extension Matomo: 4.11.0
* Config existe et est accessible en écriture.: Oui ("$abs_path/wp-content/uploads/matomo/config/config.ini.php" )
* JS Tracker existe et est accessible en écriture.: Oui ("$abs_path/wp-content/uploads/matomo/matomo.js" )
* Répertoires de l’extension: Yes ([{"pluginsPathAbsolute":"\/data\/web\/wp-content\/plugins\/matomo\/plugins","webrootDirRelativeToMatomo":"..\/"}])
* Répertoire temporaire accessible en écriture: Yes ($abs_path/wp-content/cache/matomo)
* idSite du site web Matomo: 1
* Version installée de Matomo: 4.11.0 (Install date: 2022-08-22 17:24:43)

## Endpoints

* Matomo JavaScript Tracker URL:  ($site_url/wp-content/uploads/matomo/matomo.js)
* Matomo JavaScript Tracker - WP Rest API:  ($site_url/wp-json/matomo/v1/hit/)
* Matomo HTTP Tracking API:  ($site_url/wp-content/plugins/matomo/app/matomo.php)
* Matomo HTTP Tracking API - WP Rest API:  ($site_url/wp-json/matomo/v1/hit/)

## Crons

* Heure du serveur: 2022-10-19 11:19:53
* Heure du site web: 2022-10-19 13:19:53 (Les dates ci-dessous sont affichées dans le fuseau horaire du site web)
* Sync users & sites: Next run: 2022-10-19 17:25:49 ( Last started: 2022-10-18 17:26:27. Last ended: 2022-10-06 17:27:05. Interval: daily)
* Archive: Next run: 2022-10-19 13:24:55 ( Last started: 2022-10-19 11:26:33. Last ended: 2022-10-07 13:26:09. Interval: hourly)
* Update GeoIP DB: Next run: 2022-10-21 17:25:26 ( Last started: 2022-09-21 17:26:37. Last ended: 2022-09-21 17:26:43. Interval: matomo_monthly)

## Matomo Settings

* Track mode: default
* Track codeposition: footer
* Track api endpoint: default
* Track js endpoint: default
* Version history: 4.11.0
* Core version: 4.11.0
* Last tracking settings update: 1661181949
* Last settings update: 1665765244
* Show get started page: 0

## Logs

* Aucun: 

# WordPress

* Home URL: $site_url
* Site URL: $site_url
* WordPress Version: 6.0.3
* Number of blogs: 1
* Multisite Enabled: No
* Network Enabled: No
* WP_DEBUG: Yes
* WP_DEBUG_DISPLAY: No
* WP_DEBUG_LOG: /home/web/$DB_USER/tmp/wp-errors.log
* DISABLE_WP_CRON: -
* FORCE_SSL_ADMIN: Yes
* WP_CACHE: No
* CONCATENATE_SCRIPTS: -
* COMPRESS_SCRIPTS: -
* COMPRESS_CSS: -
* ENFORCE_GZIP: -
* WP_LOCAL_DEV: -
* WP_CONTENT_URL: $site_url/wp-content
* WP_CONTENT_DIR: $abs_path/wp-content
* UPLOADS: -
* BLOGUPLOADDIR: -
* DIEONDBERROR: -
* WPLANG: -
* ALTERNATE_WP_CRON: -
* WP_CRON_LOCK_TIMEOUT: 60
* WP_DISABLE_FATAL_ERROR_HANDLER: -
* MATOMO_SUPPORT_ASYNC_ARCHIVING: -
* MATOMO_TRIGGER_BROWSER_ARCHIVING: -
* MATOMO_ENABLE_TAG_MANAGER: -
* MATOMO_SUPPRESS_DB_ERRORS: -
* MATOMO_ENABLE_AUTO_UPGRADE: -
* MATOMO_DEBUG: -
* MATOMO_SAFE_MODE: Yes
* MATOMO_GLOBAL_UPLOAD_DIR: -
* MATOMO_LOGIN_REDIRECT: -
* Permalink Structure: /%year%/%postname%/
* Possibly uses symlink: Yes
* Upload base url: $site_url/wp-content/uploads
* Upload base dir: $abs_path/wp-content/uploads
* Upload url: $site_url/wp-content/uploads/2022/10
* Custom upload_path: 
* Custom upload_url_path: 
* Compatible content directory: Yes

# WordPress Plugins


## MU Plugins

* Elementor Safe Mode: 1.0.0

## Plugins

* Advanced Custom Fields PRO: 5.12
* XXX Cotisation: 1.0.0.0
* XXX Custom Notifications: 1.0
* XXX Export des membres: 1.0.0
* Ajax Search Pro: 4.22
* Automatic Translate Addon For Loco Translate: 2.3.1
* Autoptimize: 3.1.2
* Better Search Replace: 1.4.1 (Network enabled)
* Converter for Media: 5.3.1 (Network enabled)
* Disable Emails: 1.8.1
* Disable Gutenberg: 2.8
* Elementor: 3.7.8
* Elementor Pro: 3.7.1
* Gmail SMTP: 1.2.3.2
* Loco Automatic Translate Addon PRO: 1.3.4
* Loco Translate: 2.6.2
* Matomo Analytics - Ethical Stats. Powerful Insights.: 4.11.0
* Post Type Switcher: 3.2.1
* Query Monitor: 3.10.1
* Redis Object Cache: 2.2.0 (Network enabled)
* Site Kit by Google: 1.85.0
* User Role Editor: 4.63.1
* Video Conferencing with Zoom: 4.0.6
* Watu PRO: 6.7.0.3
* When Last Login: 1.2.1
* WP User Frontend: 3.5.29
* WP User Frontend Pro - personal: 3.4.7
* Yoast SEO: 19.8
* Active Plugins: 22 (advanced-custom-fields-pro $DB_USER-cotisation $DB_USER-export $DB_USER-mails ajax-search-pro autoptimize disable-gutenberg elementor-pro elementor gmail-smtp google-site-kit matomo post-type-switcher redis-cache user-role-editor video-conferencing-with-zoom-api watupro webp-converter-for-media when-last-login wordpress-seo wp-user-frontend-pro wp-user-frontend)
* Theme: hello-elementor ($DB_USER)

# Server

* Server Info: Apache/2.4.54 (Debian)
* PHP OS: Linux
* PHP Version: 7.4.30
* PHP SAPI: fpm-fcgi
* PHP Binary Name: php-fpm7.4
* PHP Error Reporting: 0 After bootstrap: 0
* Timezone: UTC
* WP timezone: Europe/Paris
* Locale: fr_FR
* User Locale: fr_FR
* Memory Limit: 1024M (At least 128MB recommended. Depending on your traffic 256MB or more may be needed.)
* WP Memory Limit: 1024M
* WP Max Memory Limit: 512M
* Timezone version: 0.system
* Time: 1666178393
* Max Execution Time: 60
* Max Post Size: 100M
* Max Upload Size: 104857600
* Max Input Vars: 1000
* Disabled PHP functions: Yes (pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,)
* zlib.output_compression is off: Yes
* Curl Version: 7.74.0, OpenSSL/1.1.1n
* Suhosin installed: No

# Database

* MySQL Version: 5.5.5
* Mysqli Connect: Yes
* Force MySQL over Mysqli: No
* DB Prefix: wp_
* DB CHARSET: utf8mb4
* DB COLLATE: 
* SHOW ERRORS: No
* SUPPRESS ERRORS: No
* Uses Socket: No
* Uses IPv6: No
* Matomo tables found: 101
* DB tables exist: Yes
* Matomo users found: 2
* Matomo sites found: 1
* Permissions obligatoires: OK

# Browser

* Browser:  (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36)

411x avatar Oct 19 '22 11:10 411x

Hello @411x

Can you share with us a screenshot of the error?

Kind regards

Mat

mattmary avatar Oct 19 '22 21:10 mattmary

refs #233

mattmary avatar Oct 20 '22 22:10 mattmary

Here is a screenshot

matomocrash

411x avatar Oct 21 '22 10:10 411x

I have disabled all the plugins and the problem persists.

411x avatar Oct 21 '22 10:10 411x

Hello @411x

When you say that you have disabled all the plugins, do you mean that you were in a state that you had only the Matomo plugin enabled and all others plugins disabled? Or you've tried to disabled one by one your plugins, and you did not find which one is responsible for this problem? Kind regards

Mat

mattmary avatar Oct 24 '22 21:10 mattmary

Hello @mattmary

I deactivated the plugins one by one and retesting to see if the error persisted, until I had no plugins or themes activated. The error persisted.

I can try installing a fresh wordpress on the same server to see if that would be the environment that would generate this error.

411x avatar Oct 25 '22 13:10 411x

Hello @411x

These errors are mostly due to a conflict with another module.

Do you have a SSH access on your webserver? Would you be able to run the following command: find . -type d -name php-di And give me the output?

Kind regards

Mat

mattmary avatar Oct 25 '22 18:10 mattmary

Hello @411x

Any chances you read my previous comment?

Kind regards

Mat

mattmary avatar Nov 18 '22 01:11 mattmary

I was getting the same error. The conflict is with the PSR-11 container interface - Psr\Container\ContainerInterface, where another module is loading a newer version of psr/container than Matomo is.

In my case, wp-cli/wp-cli-bundle was loading psr/container version 2.0.2, but php-di only requires psr/container:^1.0 and Matomo is only providing the 1.x version of the interface.

The only difference between the interface in the most recent releases of psr/container 1.x and 2.x is that 2.x enforces a type return and 1.x does not.

thunderdw avatar Nov 23 '22 21:11 thunderdw

Related to https://github.com/matomo-org/matomo-for-wordpress/issues/233

mattmary avatar Nov 23 '22 23:11 mattmary

Hello @411x

First of all, sorry for this late reply.

This problem is a known problem: WordPress is not able to load a component version, it loads the first one found. It leads to incompatibilities with others plugins, like in your case. We are working on a solution to ensure that our component will load their own version. The fix should be published in the next major Matomo release, which should be published soon.

In the meantime, I've tried to find a solution for your problem. For now, I'm not able to reproduce this problem with the wp cli version you can download from https://wp-cli.org/. Maybe you could replace your bundle with this version, time we publish our fix?

Kind regards

Mat

mattmary avatar Dec 15 '22 22:12 mattmary

Hello @411x

Any updates from your side on this subject?

Kind regards

Mat

mattmary avatar May 09 '23 00:05 mattmary

@mattmary I just received the same error by the error reporting email. WP 6.2.2 with Matomo WP Plugin 4.15.0

I do not know if this is an error a real user have seen or it is because any background tasks, because this error was created in the night.

WordPress Plugins

MU Plugins

  • aios-firewall-loader.php:
  • WP STAGING Optimizer: 1.5.1

Plugins

  • All In One WP Security: 5.2.1 (Network enabled)
  • Backup Duplicator & Migration - WP STAGING: 3.0.0
  • Matomo Analytics - Ethical Stats. Powerful Insights.: 4.15.0
  • Real Media Library (Free): 4.21.3
  • Spectra: 2.7.3
  • UpdraftPlus - Backup/Restore: 1.23.7
  • WP-Optimize - Clean, Compress, Cache: 3.2.16
  • WPForms Lite: 1.8.2.3
  • WP Mail SMTP: 3.8.2
  • Active Plugins: 9 (all-in-one-wp-security-and-firewall matomo real-media-library-lite ultimate-addons-for-gutenberg updraftplus wp-mail-smtp wp-optimize wp-staging wpforms-lite)
  • Theme: astra (astra)

Server

  • Server Info: Apache/2.4.38 (Debian)
  • PHP OS: Linux
  • PHP Version: 7.4.33
  • PHP SAPI: fpm-fcgi
  • PHP Binary Name: /usr/local/sbin/php-fpm
  • PHP Maxmind DB extension: Not loaded
  • PHP Error Reporting: After bootstrap: 0
  • PHP Found Binary: /usr/local/bin/php -q
  • Timezone: UTC
  • WP timezone: Europe/Berlin
  • Locale: de_DE
  • User Locale: de_DE
  • Memory Limit: 512M (At least 128MB recommended. Depending on your traffic 256MB or more may be needed.)
  • WP Memory Limit: 40M
  • WP Max Memory Limit: 512M
  • Timezone version: 2022.1
  • Time: 1691077377
  • Max Execution Time: 300
  • Max Post Size: 50M
  • Max Upload Size: 52428800
  • Max Input Vars: 5000
  • Disabled PHP functions: No
  • zlib.output_compression is off: Yes
  • Curl Version: 7.64.0, OpenSSL/1.1.1n
  • Suhosin installed: No

mstenz avatar Aug 03 '23 15:08 mstenz

@mattmary

Any updates from your side on this subject?

I just tried again, with the last Matomo version

PHP Fatal error: Declaration of DI\\Container::has($name) must be compatible with Psr\\Container\\ContainerInterface::has(string $id): bool in /data/web/wp-content/plugins/matomo/app/vendor/php-di/php-di/src/Container.php on line 210 So exactly the same error?

find . -type d -name php-di

I have one result, a plugin I made using phpoffice/phpspreadsheet. (myplugin)/vendor/php-di

411x avatar Aug 06 '23 13:08 411x

Really really weird behavior.

I have just had a similar problem with Matomo plugin 4.15.3 and WP 6.1.4, PHP8.1.26

Fatal error: Declaration of DI\Container::has($name) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /homepages/30/d696797261/htdocs/monogrammemarketing/wp-content/plugins/matomo/app/vendor/php-di/php-di/src/Container.php on line 210

I have no terminal access to the server of that website but I downloaded a complete backup and ran find . -type d -name php-di

The only files returning a reference are matomo's files:

./wp-content/plugins/matomo/app/vendor/php-di
./wp-content/plugins/matomo/app/vendor/php-di/php-di

But I ran a advanced research parsing all files content and Wordfence poped up. Trying to deactivate it did not solve. I troubleshoot by deactivating all plugins and switching to default theme. Matomo works.

By reactivating individually I cornered the plugin BackWPup (v4.0.2) containing this type of lines:

Psr\\Container\\ContainerExceptionInterface' => __DIR__ . '/..' . '/psr/container/src/ContainerExceptionInterface.php',
        'Psr\\Container\\ContainerInterface' => __DIR__ . '/..' . '/psr/container/src/ContainerInterface.php',
        'Psr\\Container\\NotFoundExceptionInterface' => __DIR__ . '/..' . '/psr/container/src/NotFoundExceptionInterface.php',

Any idea how this could be fixed to allow both plugins to be used?

Julianoe avatar Nov 30 '23 17:11 Julianoe

Hi @Julianoe, this is caused by a plugin (in this case BackWPup) using the same composer dependency Matomo for WordPress uses, but at a different version. Currently the only way to solve this issue is to downgrade the offending plugin to a version that doesn't have issues. However, we are working on a fix for all of these kinds of issues which you can track via #841.

diosmosis avatar Dec 01 '23 00:12 diosmosis

Awesome, Thanks @diosmosis for keeping us updated and linking to this issue so we can follow the work. Thanks for your work on matomo!

Julianoe avatar Dec 04 '23 15:12 Julianoe

This issue should be solved in Matomo for WordPress 5, which has better compatibility with other WordPress plugins.

diosmosis avatar Feb 19 '24 22:02 diosmosis