wpmudev / multi-db

Allows you to partition your large WordPress Multisite database across multiple servers for scalability.
GNU General Public License v2.0
90 stars 64 forks source link

Trouble using Multi-DB with WooCommerce #1

Open mrbm opened 8 years ago

mrbm commented 8 years ago

When a customer attempts to perform a Translation on a WooCommerce site with with Multi-DB installed it fails.

After debugging the failure I find that a called to: get_post($order_id)

it is failing to return any results, where order_id is the returned value after using wp_insert_post

Reviewing the database reveals that wp_insert_post was performed correctly. (ie I can use phpmyadmin to see the database (wordpress_16), and the table in the database (wp_6_posts)

Doing more testing and performing the query:

$test_q = new WP_Query( array( 'p' => $order_id, 'post_type'=> array( 'product', 'product_variation', 'shop_order', 'view-orders', 'shop_coupon') ) );

Running this query shows me it is making a query to the database table wp_6_posts, but producing zero results

Nor does this work: $test_q = new WP_Query( array( 'p' => $order_id, 'post_type'=> array( 'product', 'product_variation', 'shop_order', 'view-orders', 'shop_coupon') ) ); $test_results = $wpdb->get_row($test_q->request);

HOWEVER if I do: global $exdb; $exdb= new wpdb( $wpdb->dbuser, $wpdb->dbpassword, 'wordpress_16', $wpdb->dbhost ); $test_q = new WP_Query( array( 'p' => $order_id, 'post_type'=> array( 'product', 'product_variation', 'shop_order', 'view-orders', 'shop_coupon') ) ); $test_results = $exdb->get_row($test_q->request);

Then test result will indeed show the correct data.

I also tried using the switch to blog id function but that gave no results. So the issue seems to be that the correct database is not being queried. Been having issues with other wpmu dev plugins (multipress and domain mapping) wondering if this is part of the issue.

Any immediate thoughts on my wp_insert_post can detect the correct database, however get post and WP_Query cannot? Thanks!

uglyrobot commented 8 years ago

Could there be any kind of caching plugin in between skewing your results?

mrbm commented 8 years ago

All caching is disabled, the issue I believe is multi-db for some reason is not properly setting the correct database to make the query on. My hacked solution works for woocommerce, but something is telling me this issue could be creating consequences for performance and cart issues in WPMU Dev Marketpress and the WPMU Dev Domain Mapping tool filling up the database with transient posts. Can't confirm that, but I think something is up.