monero-integrations / monerowp

Monero WooCommerce Plugin for Wordpress
MIT License
105 stars 74 forks source link

Monero -> Payments Tab Broken: "An error of type E_ERROR....Error message: Uncaught Exception: Invalid order." #102

Open xmrstickers opened 3 years ago

xmrstickers commented 3 years ago

Describe the bug The monero --> payments tab throws an uncaught exception: "There has been a critical error on this website. Please check your site admin email inbox for instructions."

Here is the stack:

An error of type E_ERROR was caused in line 104 of the file /var/www/html/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php. Error message: Uncaught Exception: Invalid order. in /var/www/html/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php:104 Stack trace:

0 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(159): Abstract_WC_Order_Data_Store_CPT->read()

1 /var/www/html/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-order.php(114): WC_Data_Store->read()

2 /var/www/html/wp-content/plugins/monero-woocommerce-gateway/include/admin/class-monero-admin-payments-list.php(154): WC_Abstract_Order->__construct()

3 /var/www/html/wp-content/plugins/monero-woocommerce-gateway/include/admin/class-monero-admin-payments-list.php(135): Monero_Admin_Payments_List->get_order_link()

4 /var/www/html/wp-admin/includes/class-wp-list-table.php(1452): Monero_Admin_Payments_List->column_default()

5 /var/www/html/wp-admin/includes/class-wp-list-table.php(1392): WP_List_Table->single_row_columns()

6 /var/www/html/wp-admin/includes/class-wp-list-table.php(1379): WP_List_Table->single_ro

To Reproduce Steps to reproduce the behavior: not entirely sure. I made a few sales, then it broke. To see where it is breaking specifically:

  1. Go to wordpress admin panel
  2. Click on "Monero" on the left-hand side
  3. Click "Payments"
  4. See error

Expected behavior It should show a total of 4 orders instead of 1 before throwing the error. The other orders are cancelled/refunded orders; perhaps there is some uncaught logic for this page handling those types of orders? I am happy to help debug this in any way I can.

WordPress version 5.8 Current theme: Storefront (version 3.7.0) Current plugin: WooCommerce (version 5.5.2) PHP version 7.4.3

Any help appreciated. My site is live and still functioning, but being unable to see past-orders is way too cumbersome if my site were due to any high-volume.

serhack commented 3 years ago

Thanks for reporting it. Looking into it. Did you enable any other plugins with your store? Do you have any particular type of orders (e.g. "preview orders")?

xmrstickers commented 3 years ago

"Did you enable any other plugins with your store?" - YES, WP fail2ban, WP Mail SMTP (to make automated email alerts easy), WPForms Lite (this may be activated for no reason, will investigate) Yoast SEO (not active!)

"Do you have any particular type of orders (e.g. "preview orders")?" I don't think so - In the WooCommerce --> Orders I only have the 1 legitimate order present. I did about 5-6 orders total before going live, to debug each order-type and all email-alerts, but it was functioning fine until recently. I have deleted all orders except the legitimate one that is status "Completed". Perhaps there is a disconnect between expected orders on WooCommerce's end compared to the monero POS? I'm just spitballing here.

Thank you for the prompt response, serhack! Please don't hesitate to ask me any more questions, I will do my best to answer them! You are most appreciated sir :)

jacobeva commented 1 year ago

I have the same issue.

jacobeva commented 1 year ago

@serhack I can still send that email if necessary, but I assume the detail @xmrstickers has given is sufficient?

jacobeva commented 1 year ago

Interesting caveat, after having deleted all records from my wp_monero_gateway_quotes_txids table in my database, the error is gone. Looks like it is an issue with cross referencing or something?

jacobeva commented 1 year ago

Hey don't mean to be a bother, but any updates on this? I'd be willing to do some more digging to help if you'd like @serhack :)

jacobeva commented 1 year ago

Just discovered triggering conditions for the error:

  1. Receive 2 monero transactions
  2. Move 1 order to the bin
  3. Delete the same order permanently
  4. Error occurs From this, I can probably deduce that it's trying to look up the order ID and failing, and that's what this error is. Therefore, some kind of check if the order exists before it's passed the WC_Order function is probably in order.

@xmrstickers Can you confirm that one or more of your orders were deleted permanently when you experienced this error?

jacobeva commented 1 year ago

PR is open, my work here is done :)