Closed rumpelstilzchen94 closed 4 years ago
Hi,
I haven't encountered this error yet, nor was I able to recreate it now. Do you run any child themes for Storefront? Do you have any other plugins active at the same time by any chance? Can you please provide your System status report?
Having a quick look now, cart initialization happens much sooner than function storefront_cart_link
runs.
It seems to me that if cart is null
when this code runs, it means the storefront_cart_link
either runs before the cart has been initialized (which means something calls it way too soon), or something changes cart to null
in between (which I could not find in WC/Storefront code).
`
WordPress address (URL): http://xxx.xxx Site address (URL): http://xxx.xxx WC Version: 3.6.5 Log Directory Writable: ✔ WP Version: 5.2.2 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: de_DE External object cache: –
Server Info: LiteSpeed PHP Version: 5.6.40 - Wir empfehlen PHP Version 7.2 oder höher für mehr Leistung und Sicherheit zu verwenden. So aktualisierst du deine PHP-Version
PHP Post Max Size: 16 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 7.65.3 OpenSSL/1.0.2s
SUHOSIN Installed: – MySQL Version: 5.6.44 Max Upload Size: 16 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔
WC Database Version: 3.6.5 WC Database Prefix: wpjs_ Datenbank-Gesamtgröße: 27.44MB Datenbank-Datengröße: 20.55MB Datenbank-Indexgröße: 6.89MB wpjs_woocommerce_sessions: Daten: 0.10MB + Index: 0.00MB wpjs_woocommerce_api_keys: Daten: 0.00MB + Index: 0.01MB wpjs_woocommerce_attribute_taxonomies: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_downloadable_product_permissions: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_order_items: Daten: 0.03MB + Index: 0.02MB wpjs_woocommerce_order_itemmeta: Daten: 0.16MB + Index: 0.11MB wpjs_woocommerce_tax_rates: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_tax_rate_locations: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_shipping_zones: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_shipping_zone_locations: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_shipping_zone_methods: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_payment_tokens: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_payment_tokenmeta: Daten: 0.00MB + Index: 0.00MB wpjs_woocommerce_log: Daten: 0.00MB + Index: 0.00MB cerber_acl: Daten: 0.00MB + Index: 0.00MB cerber_blocks: Daten: 0.00MB + Index: 0.00MB cerber_countries: Daten: 0.00MB + Index: 0.00MB cerber_lab: Daten: 0.00MB + Index: 0.00MB cerber_lab_ip: Daten: 0.00MB + Index: 0.00MB cerber_lab_net: Daten: 0.00MB + Index: 0.00MB cerber_log: Daten: 0.04MB + Index: 0.02MB cerber_qmem: Daten: 0.00MB + Index: 0.00MB cerber_traffic: Daten: 0.33MB + Index: 0.02MB crypto_files: Daten: 0.02MB + Index: 0.31MB crypto_membership: Daten: 0.02MB + Index: 0.09MB crypto_payments: Daten: 0.02MB + Index: 0.31MB crypto_products: Daten: 0.02MB + Index: 0.25MB wpjs_bwg_album: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_album_gallery: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_file_paths: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_gallery: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_image: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_image_comment: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_image_rate: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_image_tag: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_shortcode: Daten: 0.00MB + Index: 0.00MB wpjs_bwg_theme: Daten: 0.04MB + Index: 0.00MB wpjs_cerber_files: Daten: 1.91MB + Index: 0.25MB wpjs_cerber_sets: Daten: 0.03MB + Index: 0.00MB wpjs_cerber_uss: Daten: 0.00MB + Index: 0.00MB wpjs_commentmeta: Daten: 0.00MB + Index: 0.01MB wpjs_comments: Daten: 0.12MB + Index: 0.06MB wpjs_give_donormeta: Daten: 0.00MB + Index: 0.00MB wpjs_give_donors: Daten: 0.00MB + Index: 0.00MB wpjs_give_formmeta: Daten: 0.00MB + Index: 0.00MB wpjs_give_logmeta: Daten: 0.00MB + Index: 0.00MB wpjs_give_logs: Daten: 0.00MB + Index: 0.00MB wpjs_give_paymentmeta: Daten: 0.00MB + Index: 0.00MB wpjs_inbound_events: Daten: 0.00MB + Index: 0.00MB wpjs_inbound_page_views: Daten: 0.00MB + Index: 0.00MB wpjs_inbound_tracked_links: Daten: 0.00MB + Index: 0.00MB wpjs_ip_geo_block_cache: Daten: 0.00MB + Index: 0.00MB wpjs_ip_geo_block_logs: Daten: 0.21MB + Index: 0.02MB wpjs_ip_geo_block_stat: Daten: 0.00MB + Index: 0.00MB wpjs_links: Daten: 0.00MB + Index: 0.00MB wpjs_lockdowns: Daten: 0.17MB + Index: 0.06MB wpjs_loginizer_logs: Daten: 0.00MB + Index: 0.00MB wpjs_login_fails: Daten: 0.64MB + Index: 0.23MB wpjs_nf3_actions: Daten: 0.00MB + Index: 0.00MB wpjs_nf3_action_meta: Daten: 0.02MB + Index: 0.01MB wpjs_nf3_fields: Daten: 0.00MB + Index: 0.00MB wpjs_nf3_field_meta: Daten: 0.81MB + Index: 0.02MB wpjs_nf3_forms: Daten: 0.00MB + Index: 0.00MB wpjs_nf3_form_meta: Daten: 0.01MB + Index: 0.00MB wpjs_nf3_objects: Daten: 0.00MB + Index: 0.00MB wpjs_nf3_object_meta: Daten: 0.00MB + Index: 0.00MB wpjs_nf3_relationships: Daten: 0.00MB + Index: 0.00MB wpjs_ngg_album: Daten: 0.00MB + Index: 0.00MB wpjs_ngg_gallery: Daten: 0.00MB + Index: 0.00MB wpjs_ngg_pictures: Daten: 0.01MB + Index: 0.00MB wpjs_optins: Daten: 0.00MB + Index: 0.00MB wpjs_optin_meta: Daten: 0.01MB + Index: 0.01MB wpjs_options: Daten: 2.02MB + Index: 0.06MB wpjs_postmeta: Daten: 0.78MB + Index: 0.52MB wpjs_posts: Daten: 0.79MB + Index: 0.06MB wpjs_statistics_exclusions: Daten: 0.00MB + Index: 0.00MB wpjs_statistics_historical: Daten: 0.00MB + Index: 0.00MB wpjs_statistics_pages: Daten: 0.22MB + Index: 0.47MB wpjs_statistics_search: Daten: 0.40MB + Index: 0.27MB wpjs_statistics_useronline: Daten: 0.01MB + Index: 0.00MB wpjs_statistics_visit: Daten: 0.01MB + Index: 0.03MB wpjs_statistics_visitor: Daten: 2.91MB + Index: 3.60MB wpjs_termmeta: Daten: 0.00MB + Index: 0.01MB wpjs_terms: Daten: 0.00MB + Index: 0.01MB wpjs_term_relationships: Daten: 0.00MB + Index: 0.00MB wpjs_term_taxonomy: Daten: 0.00MB + Index: 0.00MB wpjs_usermeta: Daten: 0.10MB + Index: 0.01MB wpjs_users: Daten: 0.00MB + Index: 0.01MB wpjs_wc_download_log: Daten: 0.00MB + Index: 0.00MB wpjs_wc_product_meta_lookup: Daten: 0.00MB + Index: 0.01MB wpjs_wc_webhooks: Daten: 0.00MB + Index: 0.00MB wpjs_wpfm_backup: Daten: 0.00MB + Index: 0.00MB wpjs_wpml_mails: Daten: 8.59MB + Index: 0.01MB wpjs_yoast_seo_links: Daten: 0.00MB + Index: 0.00MB wpjs_yoast_seo_meta: Daten: 0.00MB + Index: 0.01MB
amn_wpforms-lite: 3 attachment: 14 bwg_album: 1 bwg_gallery: 1 bwg_share: 1 custom_css: 1 display_type: 7 landing-page: 1 nav_menu_item: 6 nf_sub: 1 ngg_album: 2 ngg_gallery: 10 ngg_pictures: 38 page: 10 popup: 1 popup_theme: 6 popups: 1 post: 1 product: 3 revision: 133 scheduled-action: 14 shop_coupon: 8 shop_order: 210 shop_order_refund: 5 spucpt: 1 wpcr3_review: 5 wpforms: 1 xlwcty_thankyou: 1
Secure connection (HTTPS): ❌ Dein Shop benutzt kein HTTPS. Erfahre mehr über HTTPS und SSL-Zertifikate. Hide errors from visitors: ✔
NextGEN Gallery: von Imagely – 3.2.10 Classic Editor: von WordPress-Mitwirkende – 1.5 Cookie Notice: von dFactory – 1.2.46 Decorator - WooCommerce Email Customizer: von RightPress – 1.0.3 – Nicht getestest mit der aktiven WooCommerce-Version Error Log Monitor: von Janis Elsts – 1.6.6 Head, Footer and Post Injections: von Stefano Lissa – 3.1.3 IP Geo Block: von tokkonopapa – 3.0.17.4 Login LockDown: von Michael VanDeMar – v1.7.1 MIMO Woocommerce Order Tracking: von Surakrai Nookong – 1.0.2 – Nicht getestest mit der aktiven WooCommerce-Version My Custom Functions: von Space X-Chimp – 4.38.1 Photo Gallery: von Photo Gallery Team – 1.5.31 Codup WooCommerce Profit Reporting: von Codup.io – 1.1.3.9 – Nicht getestest mit der aktiven WooCommerce-Version Simple IP Ban: von Sandor Kovacs – 1.3.0 Tawk.to Live Chat: von Tawkto – 0.3.8 UpdraftPlus - Backup/Restore: von UpdraftPlus.Com DavidAnderson – 1.16.16
Checkout Field Editor for WooCommerce: von ThemeHiGH – 1.3.4 WooCommerce Custom Add To Cart Button: von Barn2 Media – 1.0 – Nicht getestest mit der aktiven WooCommerce-Version Woo Custom Stock Status: von Softound Solutions – 1.1.2 – Nicht getestest mit der aktiven WooCommerce-Version NextMove Lite - Thank You Page for WooCommerce: von XLPlugins – 2.10.0 WooCommerce DYMO Print: von WP Fortune – 5.0.8 – Nicht getestest mit der aktiven WooCommerce-Version WooCommerce Lieferzeitschätzungen: von SkyVerge – 2.2.0 – Nicht getestest mit der aktiven WooCommerce-Version WooCommerce: von Automattic – 3.6.5 Yoast SEO: von Team Yoast – 11.7 – Nicht getestest mit der aktiven WooCommerce-Version WP Cerber Security, Antispam & Malware Scan: von Cerber Tech Inc. – 8.4 WP Customer Reviews: von Go Web Solutions – 3.4.1 WP-Dateimanager: von mndpsingh287 – 5.2 WP Mail Logging: von Christian Zöller – 1.9.1 WP Review: von MyThemeShop – 5.2.4 WP Statistics: von VeronaLabs – 12.6.7 WPForms Lite: von WPForms – 1.5.3.1 WP Fortune: von WP Fortune – 1.0.8
17TRACK for WooCommerce: von 17TRACK – 1.0.8 – Nicht getestest mit der aktiven WooCommerce-Version Age Verify: von Chase Wiseman – 0.3.0 Landing Pages: von Inbound Now – 2.7.8 Loginizer: von Raj Kothari – 1.4.2 Theme Customisations: von WooThemes – 1.0.0 WooCommerce Waitlist: von XootiX – 1.4 – Nicht getestest mit der aktiven WooCommerce-Version Woo Out Of Stock Products: von Andrew Gunn – 2.3 – Nicht getestest mit der aktiven WooCommerce-Version Woo Payments By Shipping: von Piotr Urbanowicz – 1.0.0 – Nicht getestest mit der aktiven WooCommerce-Version
API Enabled: ✔ Force SSL: – Currency: EUR (€) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable)
Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5)
Connected to WooCommerce.com: –
Shop-Basis: #269 - /shop/ Warenkorb: #270 - /warenkorb/ Kasse: #271 - /kasse/ Mein Konto: #272 - /mein-konto/ Allgemeine Geschäftsbedingungen: ❌ Seite nicht festgelegt
Name: Storefront Version: 2.5.1 Author URL: https://woocommerce.com/ Child Theme: ❌ – Wenn du WooCommerce mit einem Theme das du nicht selbst entwickelt hast an eigene Bedürfnisse anpasst dann empfehlen wir die Verwendung eines Child-Themes. Siehe Wie du ein Child-Theme erstellst (engl.)
WooCommerce Support: ✔
Overrides: –
Complete: 14 Oldest: 2019-07-27 20:00:49 +0200 Newest: 2019-07-27 20:01:22 +0200
Pending: 0 Oldest: – Newest: –
Canceled: 0 Oldest: – Newest: –
In-progress: 0 Oldest: – Newest: –
Failed: 0 Oldest: – Newest: –
`
Thanks. I can see you have 31 plugins active. Would you be able to troubleshoot this problem on a copy of your production website to see if it happens only with WooCommerce and Storefront active? Otherwise it might be quite difficult for us to pin down the issue.
I'm also seeing this error :
[28-Sep-2019 19:41:58 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_cart_subtotal() on null in /var/www/website.com/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php:77 Stack trace:
0 /var/www/website.com/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php(120): storefront_cart_link()
1 /var/www/website.com/html/wp-includes/class-wp-hook.php(286): storefront_header_cart('')
#2 /var/www/website.com/html/wp-includes/class-wp-hook.php(310): WP_Hook-> apply_filters(NULL, Array)
3 /var/www/website.com/html/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
4 /var/www/website.com/html/wp-content/themes/storefront/header.php(46): do_action('storefront_head...')
5 /var/www/website.com/html/wp-includes/template.php(722): require_once('/var/www/woocom...')
6 /var/www/website.com/html/wp-includes/template.php(671): load_template('/var/www/woo in /var/www/website.com/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php on line 77
These errors are showing on a testing site so there isn't a lot of traffic. I can not see anything in the access log that relates to the times of the errors.
Perhaps this is related https://github.com/woocommerce/woocommerce/issues/24261
I reproduced this specific error (Call to a member function get_cart_subtotal() on null
) when testing #1239. Note that my request was for a malformed API url, which produced a 404 response, which I believe caused the error. Bad url was /wordpress/wp-json/wp/v2/users/
(should be /wp-json/wp/v2/users/
). I'm thinking this is caused by a bad request rather than an issue in storefront.
Note that a regular 404 response (e.g. /non-existent-page
) does not cause the error.
I'm also seeing this error :
[28-Sep-2019 19:41:58 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_cart_subtotal() on null in /var/www/website.com/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php:77 Stack trace:
0 /var/www/website.com/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php(120): storefront_cart_link()
1 /var/www/website.com/html/wp-includes/class-wp-hook.php(286): storefront_header_cart('')
#2 /var/www/website.com/html/wp-includes/class-wp-hook.php(310): WP_Hook-> apply_filters(NULL, Array)
3 /var/www/website.com/html/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
4 /var/www/website.com/html/wp-content/themes/storefront/header.php(46): do_action('storefront_head...')
5 /var/www/website.com/html/wp-includes/template.php(722): require_once('/var/www/woocom...')
6 /var/www/website.com/html/wp-includes/template.php(671): load_template('/var/www/woo in /var/www/website.com/html/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php on line 77
It does not happen during checkout
These errors are showing on a testing site so there isn't a lot of traffic. I can not see anything in the access log that relates to the times of the errors.
I'm experiencing this too, same stack trace.
@haszari Do you think this issue might have its origin in database changes that took place with the 3.0 release of WooCommerce? (This is just a wild guess while I’m on my phone and was searching for potential issues.)
I just had the same issue. The issue was my nginx configuration, I've found the solution on StackOverflow. I was missing the following location in my config:
location ~ ^/wp-json/ {
# if permalinks not enabled
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}
So basically, it's e.g. site.com/?rest_route=/wp/v2/posts
instead of site.com/wp-json/wp/v2/posts
Thanks for sharing your solution here, @locomoco28! 🙌
I just had the same issue. The issue was my nginx configuration, I've found the solution on StackOverflow. I was missing the following location in my config:
location ~ ^/wp-json/ { # if permalinks not enabled rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last; }
So basically, it's e.g.
site.com/?rest_route=/wp/v2/posts
instead ofsite.com/wp-json/wp/v2/posts
This fixed my issue. Thanks for posting this @locomoco28!
Based on the above comments, there's a workaround which solves this problem. Closing - please open a new issue if needed.
Reopening this as we've had more reports of this same error on WordPress.com eCommerce plan sites.
It's likely that these fatal errors are firing when WordPress is trying to render an invalid url. It's unlikely that this is affecting normal shopper / admin page requests - potentially caused by a bad incoming link or bot traffic.
In Storefront we can protect against the fatal error by adding a preflight check of WC()->cart
before dereferencing :)
Likely reproduce steps:
{domain}/new//wp-json/wp/v2/users/
.Thanks to @jmdodd for narrowing this down!
cc @nerrad - let's get this in an upcoming release, no particular urgency but will be good to tidy this up.
Added to 2.6.0, feel free to bump to next release if 2.6 is too tight :)
2.6.0 seems like a good target 👍
My error_log is quite big (2GB) and I get the following error a few times a day:
Fatal error: Call to a member function get_cart_subtotal() on null in /home/abc/www.link.to/wp-content/themes/storefront/inc/woocommerce/storefront-woocommerce-template-functions.php on line 77
Line 73-81:
Any idea what could cause the error? Wordpress, Woocommerce, Storefront is up to date.