Abstract_WC_Order_Data_Store_CPT::delete_items() query fails on HyperDB #46639
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
Prerequisites
Describe the bug
The query to delete the order item meta in
Abstract_WC_Order_Data_Store_CPT::delete_items()
uses theDELETE FROM {alias} USING {table} {alias}
format. WordPress core'swpdb::get_table_from_query()
does not support this query format. HyperDB relies onwpdb::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",
toTests_DB::data_get_table_from_query()
as a format to testwpdb::get_table_from_query()
with.WordPress Environment
Multisite environment running on HyperDB
Isolating the problem
The text was updated successfully, but these errors were encountered: