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

Abstract_WC_Order_Data_Store_CPT::delete_items() query fails on HyperDB #46639

Closed
5 tasks done
prettyboymp opened this issue Apr 16, 2024 · 0 comments · Fixed by #46692
Closed
5 tasks done

Abstract_WC_Order_Data_Store_CPT::delete_items() query fails on HyperDB #46639

prettyboymp opened this issue Apr 16, 2024 · 0 comments · Fixed by #46692
Labels
focus: order Issues related to orders. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Proton WC Core development and maintenance

Comments

@prettyboymp
Copy link
Contributor

Prerequisites

  • I have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

The query to delete the order item meta in Abstract_WC_Order_Data_Store_CPT::delete_items() uses the DELETE FROM {alias} USING {table} {alias} format. WordPress core's wpdb::get_table_from_query() does not support this query format. HyperDB relies on wpdb::get_table_from_query() to determine what dataset to connect to for a give query, but is unable to do so for this deletion because the table name cannot be parsed.

This results in an error (usually hidden) and orphaned data that is never deleted.

Expected behavior

The query should be successful on HyperDB - and

Actual behavior

wpdb::get_table_from_query() is unable able to parse out the main table in the query.

Steps to reproduce

Testing requires setting up a site with HyperDB and watching logs.
Then delete an order permanently.

An alternative to see the wpdb compatibility is to setup WordPress core phpunit tests and add "DELETE FROM a USING $table a", to Tests_DB::data_get_table_from_query() as a format to test wpdb::get_table_from_query() with.

WordPress Environment

Multisite environment running on HyperDB

Isolating the problem

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.
@lanej0 lanej0 added focus: order Issues related to orders. team: Proton WC Core development and maintenance labels Apr 17, 2024
@Konamiman Konamiman added the priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: order Issues related to orders. priority: normal The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc. team: Proton WC Core development and maintenance
Projects
None yet
3 participants