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

Fatal Error on 2.9.5 #2894

Closed
ainsleyclark opened this issue Dec 10, 2024 · 8 comments
Closed

Fatal Error on 2.9.5 #2894

ainsleyclark opened this issue Dec 10, 2024 · 8 comments
Labels
duplicate This issue or pull request already exists third-party Issues relating to third-party plugins

Comments

@ainsleyclark
Copy link

ainsleyclark commented Dec 10, 2024

Describe the Bug

After updating to v2.9.5 I receive the following error which has bricked a production site:

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 in /var/www/my-website/wp-content/plugins/woocommerce-paypal-payments/modules/woocommerce-logging/src/Logger/WooCommerceLogger.php on line 58

@robertkinsella
Copy link

Experienced the same issue here today also - I have had to revert back to v2.9.4 for the site to function again.

@goodjobjohn
Copy link

goodjobjohn commented Dec 10, 2024

Experienced the same issue here today also - I have had to revert back to v2.9.4 for the site to function again.

+1

@SydeKrystian
Copy link
Collaborator

Hello @ainsleyclark

The fatal error is triggered because our plugin uses a previous version of psr/log , as defined in woocommerce-paypal-payments/blob/trunk/composer.json with "psr/log": "^1.1" . The more recent version that would be compatible with PHP 8.2 is this one: https://packagist.org/packages/psr/log#3.0.0. The Psr/log version 3.0.0 requires PHP version 8.0.0 or higher and uses Union types in its arguments, which PayPal Payments doesn’t support yet.

Most likely, some other plugin on your site implements the library psr/log in version 3.0.0 which is not compatible with the version used in PayPal Payments.

The first step would be to isolate the cause of the conflict, so you may want to perform a full conflict test to understand which other plugin may be involved. We recommend temporarily activating the default theme Storefront and disabling all other plugins except for WooCommerce and PayPal Payments, and then enabling other plugins one by one to see when the error occurs.

Once you know which other plugin implements this version of the dependency, you could potentially ask the other plugin developer to consider downgrading the dependency version.

Should you need any more help, feel free to reach out.

Kind Regards,
Krystian

@jjmoody
Copy link

jjmoody commented Dec 13, 2024

I have the same issue; no one will be downgrading for PayPal. I suggest PayPal upgrade or see customers move on to other payment options—just a thought.

@ainsleyclark
Copy link
Author

Hi @SydeKrystian,

Thanks for your reply.

I understand the plugin currently relies on psr/log "^1.1". Upgrading to a version compatible with PHP 8.2 (such as 2.x or 3.x) should maintain backwards compatibility unless there are specific constraints within the plugin.

Running a full conflict test is resource-intensive, and the issue seems related to dependency management rather than a conflict with other plugins.

Thank you.

@lvvvvvl
Copy link

lvvvvvl commented Dec 15, 2024

I'm not sure if it's related to the same error, but after updating to hosting to PHP 8.2 and updating Woocommerce Paypal Payments to 2.9.5 on the same day, my kinsta hosting error log is flooding with these errors and I haven't had any sales since I did the updates 3 days ago (which is rare) even though my front and backend of the site don't display any errors or issues for me:

2024/12/14 00:51:16 [error] 6850#6850: *698283 FastCGI sent in stderr: “PHP message: PHP Fatal error: Uncaught Error: Call to undefined function WooCommerce\PayPalCommerce\Blocks\wc_terms_and_conditions_page_id() in /www/shop_225/public/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-blocks/extensions.php:47

Stack trace:

#0 /www/shop_225/public/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php(133): WooCommerce\PayPalCommerce\Blocks\BlocksModule->WooCommerce\PayPalCommerce\Blocks\{closure}(Array, Object(WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer))

#1 /www/shop_225/public/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php(72): WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer->resolveExtensions(‘wcgateway.setti…’, Array)

#2 /www/shop_225/public/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/services.php(549):” while reading response header from upstream, client: 188.74.137.134, server: shop.mysite.com, request: “GET /terms-and-conditions/?customize_changeset_uuid=e4d7dafb-388f-484b-8355-cd903276b3ac&customize_messenger_channel=preview-0 HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php8.2-fpm-shop.sock:”, host: `“shop.mysite.com:64493”

How do I isolate what plugin could be conflicting if the front end works fine, and the error log doesn’t follow any pattern of how frequently the error is occuring?`

Is this related to the same issue and if so should I downgrade to 2.9.4 oe reverse the PHP 8.2 to 8.1 again?

@InpsydeNiklas InpsydeNiklas added duplicate This issue or pull request already exists third-party Issues relating to third-party plugins labels Dec 27, 2024
@InpsydeNiklas
Copy link
Member

This error stems from a longstanding conflict between dependency versions, not solely from PayPal Payments. Our plugin depends on psr/log version ^1.1, which is compatible with most setups. The psr/log version 3.x introduced by another plugin, as reported in this issue, is incompatible due to changes in its argument types.

This is a dependency conflict and not a bug in PayPal Payments. Compatibility issues of this nature always involve at least two parties. The error points to PayPal Payments because it relies on a specific version of psr/log, but it’s equally true that the other plugin could downgrade, or better, scope their dependencies to avoid such conflicts.

A long-term solution is in development: We’re working to scope the dependencies to prevent such conflicts, regardless of what other plugins do. However even after we addressed this, your other plugins that currently clash with PayPal Payments still have the potential to clash with other plugins. This is an issue with the entire plugin ecosystem and a balancing act.
In the interim, I suggest following @SydeKrystian's advice to identify the conflicting plugin and report the need for better dependency management to their developers accordingly.
Updating to psr/log version 3.x is not an option as long as PayPal Payments supports PHP 7.4 (which a significant number of users are still on). While doing so may fix the problem for some users, it will break compatibility for other users on older PHP versions or with other plugins relying on psr/log version 1.x or 2.x. So it would simply shift the error from you to others (likely a larger number of users).

@lvvvvvl This is an unrelated issue. The root cause is improper gateway instantiation by a third-party plugin, like the "Cardlink" payment plugin. The error points to PayPal Payments because it uses a WooCommerce core function (wc_terms_and_conditions_page_id) on the settings pages, which may fail when other plugins incorrectly instantiate the gateways too early, before WooCommerce fully loaded. This has been improved in #2766 to better safeguard against other plugins doing it wrong and will be part of one of the next updates.

To summarize, in both cases, the errors trace back to external factors:

  • For the psr/log conflict, it’s the introduction of a version-incompatible dependency (psr/log 3.x) by another plugin
  • For the undefined function error, it’s the mishandling of WooCommerce gateway instances by a third-party plugin

I will close this issue as a duplicate of #1518, but a proper solution for this dependency conflict can be expected sometime in Q1 2025.

@ablears
Copy link

ablears commented Jan 13, 2025

Here we are in 2025 experiencing this issue because of support for PHP 7.4 which reached end of life in 2022. Come on. We are stuck on 2.9.4 until this is properly addressed. We run over 100 plugins on a large network and this is the only plugin that causes a fatal error due to this. Please, support PHP 8.x properly and scope your dependencies correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists third-party Issues relating to third-party plugins
Projects
None yet
Development

No branches or pull requests

8 participants