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 Notice: get_cart function called incorrectly before wp_loaded action - debug.log cluttered on every page load #2591

Open
s-a-s-k-i-a opened this issue Sep 12, 2024 · 0 comments

Comments

@s-a-s-k-i-a
Copy link

s-a-s-k-i-a commented Sep 12, 2024

I am encountering a PHP notice related to the get_cart function in WooCommerce on every page visit of the production website. The notice indicates that get_cart is being called incorrectly, as it should not be called before the wp_loaded action. This issue seems related to the WooCommerce PayPal Payments plugin.

Error message:
[12-Sep-2024 11:12:08 UTC] PHP Notice: Die Funktion get_cart wurde <strong>fehlerhaft</strong> aufgerufen. „Get cart“ sollte nicht vor der Action „wp_loaded“ aufgerufen werden. Backtrace: require_once('wp-load.php'), require_once('/var/www/.../wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry-&gt;initialize, do_action('woocommerce_blocks_payment_method_type_registration'), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, WooCommerce\PayPalCommerce\Blocks\BlocksModule-&gt;WooCommerce\PayPalCommerce\Blocks\{closure}, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\CachingContainer-&gt;get, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\CachingContainer-&gt;getCached, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\CachingContainer-&gt;invokeGenerator, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\CachingContainer-&gt;WooCommerce\PayPalCommerce\Vendor\Dhii\Container\{closure}, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\CompositeContainer-&gt;get, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\DelegatingContainer-&gt;get, WooCommerce\PayPalCommerce\Vendor\Dhii\Container\DelegatingContainer-&gt;invokeFactory, WooCommerce\PayPalCommerce\Blocks\BlocksModule::WooCommerce\PayPalCommerce\Blocks\{closure}, WC_Cart-&gt;needs_shipping, apply_filters('woocommerce_cart_needs_shipping'), WP_Hook-&gt;apply_filters, ek_filter_cart_needs_shipping, WC_Cart-&gt;get_cart, WC_Cart_Session-&gt;get_cart_from_session, WC_Cart-&gt;calculate_totals, WC_Cart_Session-&gt;set_session, WC_Cart_Session-&gt;get_cart_for_session, WC_Cart-&gt;get_cart, wc_doing_it_wrong Weitere Informationen: <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress (engl.)</a>. (Diese Meldung wurde in Version 2.3 hinzugefügt.) in /var/www/.../htdocs/wp-includes/functions.php on line 6085

To Reproduce

  1. Visit any page on the production website.
  2. Check the PHP error logs.
  3. See the PHP notice related to get_cart.

Expected Behavior

The get_cart function should only be called after the wp_loaded action to avoid PHP notices. No error messages should be logged.

Actual Behavior

A PHP notice is logged on every page visit, indicating that the get_cart function was called too early.

Environment

  • WordPress Version: 6.6.2
  • WooCommerce Version: 9.2.3
  • WooCommerce PayPal Payments Plugin Version: 2.9.0
  • PHP Version: 8.1.29
  • Server Environment: nginx/1.26.2
System status
WordPress Environment

WP Version: 6.6.2
WC Version: 9.2.3
WooCommerce PayPal Payments Plugin Version: 2.9.0
PHP Version: 8.1.29
Server Info: nginx/1.26.2
...
<!-- Further details redacted for privacy reasons. -->
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

1 participant