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

Trouble using Multi-DB with WooCommerce #1

Open
mrbm opened this issue Jan 25, 2016 · 2 comments
Open

Trouble using Multi-DB with WooCommerce #1

mrbm opened this issue Jan 25, 2016 · 2 comments

Comments

@mrbm
Copy link

mrbm commented Jan 25, 2016

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
Copy link
Contributor

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

@mrbm
Copy link
Author

mrbm commented Jan 25, 2016

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.

uglyrobot pushed a commit that referenced this issue Apr 12, 2018
 PHP 7 - Updated db.php for existing multi-db installations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants