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

Logger interface incompatible with Psr\Log\LoggerTrait:log() (968) #1518

Open
areklam opened this issue Jul 18, 2023 · 2 comments · May be fixed by #1519
Open

Logger interface incompatible with Psr\Log\LoggerTrait:log() (968) #1518

areklam opened this issue Jul 18, 2023 · 2 comments · May be fixed by #1519
Labels
third-party Issues relating to third-party plugins

Comments

@areklam
Copy link

areklam commented Jul 18, 2023

Describe the Bug

The WooCommerce logging interface module attempt to use Psr\Log\LoggerTrait with invalid interface. The classes WooCommerceLogger and NullLogger both implement Psr\Log\LoggerInterface and declare the log function without a function return type.

The solution is to include the return type for the log functions which is supposed to be void.

To Reproduce

  1. Install and activate plugin
  2. See error

Screenshots

Screenshot 2023-07-18 at 16 50 58

Expected Behavior

Plugin activated, no errors.

Actual Behavior

Error message
Fatal error: Declaration of WooCommerce\WooCommerce\Logging\Logger\WooCommerceLogger::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerTrait::log($level, Stringable|string $message, array $context = []): void

Environment

  • WordPress Version 6.2.2
  • WooCommerce Version 7.9.0
  • Plugin Version 2.2.0
  • Roots Bedrock
@areklam areklam linked a pull request Jul 18, 2023 that will close this issue
@InpsydeNiklas InpsydeNiklas added the third-party Issues relating to third-party plugins label Jul 18, 2023
@InpsydeNiklas InpsydeNiklas changed the title Logger interface incompatible with Psr\Log\LoggerTrait:log() Logger interface incompatible with Psr\Log\LoggerTrait:log() (968) Jul 18, 2023
@InpsydeNiklas
Copy link
Member

Hi @areklam, thanks for the issue & PR.
However, psr/log version 3.0.0 supports only php >=8.0.0 and the declaration of arguments are using “Union types”, as seen here. PayPal Payments supports PHP 7.2, so it cannot be made compatible with this at this time. This means the primary suggestion would be to downgrade this library in your theme, while the development team is investigating other ways to improve the compatibility with third-party plugins/themes that use a newer psr/log version.

@williarin
Copy link

Hi, using Sword (Bedrock-like for Symfony) this error makes it impossible to use this plugin as well.
Maybe it's too late at this stage of development, but an option would be to prefix namespaces with https://github.com/typisttech/imposter-plugin so there's no conflict to external plugins or apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
third-party Issues relating to third-party plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants