It definitely is reproducing, albeit not as often as I would expect.
the example errors are:
[16-Jun-2018 10:04:54 UTC] Error Table ‘<mysite>_www.usermeta’ doesn’t exist de la base de datos de WordPress para la consulta INSERT INTO usermeta( user_id, meta_key, meta_value )
VALUES ( ’93’, ‘_woocommerce_persistent_cart’,
I don’t understand what this user_id is: there is no user and the the user_id passed is sequentially increasing with every error in a way that has nothing to do with the actual user ids.
Tracing through your code I can see where the problem is but so far I don’t have clear what the code is trying to do or why…
in wcal_class_guest.php
This action is hooked only if the user is not logged in:
if ( ! is_user_logged_in() ) {
add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
}
and the function then reconfirms the user is not logged in:
function save_data() {
if ( ! is_user_logged_in() ) {
ll 272+ there is code like:
if( is_multisite() ) {
// get main site's table prefix
$main_prefix = $wpdb->get_blog_prefix(1);
$insert_persistent_cart = "INSERT INTO <code>" . $wpdb->main_prefix . "usermeta</code>( user_id, meta_key, meta_value )
VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
$wpdb->query( $insert_persistent_cart );
} else {
$insert_persistent_cart = "INSERT INTO <code>" . $wpdb->prefix . "usermeta</code>( user_id, meta_key, meta_value )
VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
$wpdb->query( $insert_persistent_cart );
Well, from the logs it looks like in certain circumstances $wpdb->get_blog_prefix(1) might not be getting the right value, but even without that, there is no real $user_id and it doesn’t seem make sense to be updating the persistent cart of a fake/random user id?
The $user_id is an id returned from the insert of an anoymous user into ac_abandoned_cart_history_lite
//Insert record in abandoned cart table for the guest user
$user_id = $wpdb->insert_id;
, it should not be used to update a record in the real wordpress usermeta table.
So I’m wondering whether I can ignore or comment out this part of the code or really what is it supposed to be doing?