Skip to content

Trouble using Multi-DB with WooCommerce #1

@mrbm

Description

@mrbm

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions