wc_load_cart() calling a lot of rows for wpms superadmin
-
In a wpms installation with many sites, for superadmin, wc_load_cart() from woocommerce/includes/class-woocommerce.php:666 is resulting in a lot of rows being called, which can break database. What is the best way to fix that?
SELECT umeta_id as meta_id, meta_key, meta_value FROM wpsoft_usermeta WHERE user_id = 1 ORDER BY umeta_id
Function path:
WC_Data_Store_WP->read_meta() wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php:94 WC_Data_Store->__call() wp-content/plugins/woocommerce/includes/class-wc-data-store.php:224 WC_Data->read_meta_data() wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-data.php:633 WC_Customer_Data_Store->read() wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php:179 WC_Data_Store->read() wp-content/plugins/woocommerce/includes/class-wc-data-store.php:159 WC_Customer->__construct() wp-content/plugins/woocommerce/includes/class-wc-customer.php:113 WooCommerce->initialize_cart() wp-content/plugins/woocommerce/includes/class-woocommerce.php:847 wc_load_cart() wp-content/plugins/woocommerce/includes/wc-core-functions.php:2574 WooCommerce->init() wp-content/plugins/woocommerce/includes/class-woocommerce.php:666 do_action('init') wp-includes/plugin.php:517
What ChatGPT said about the matter:
“The query you provided selects rows from the wpsoft_usermeta table in a WordPress Multisite (WPMS) installation with WooCommerce. It retrieves the umeta_id, meta_key, and meta_value columns where the user_id is 1, ordered by umeta_id.
The query is part of the WooCommerce plugin’s functionality to read metadata associated with a user. It is executed within the context of the WC_Data_Store_WP class, specifically the read_meta() method. This method is called through the WC_Data_Store class, which acts as a base class for data stores in WooCommerce.
The query is used to retrieve the metadata of a customer with user_id 1. It seems to be part of the process of initializing the customer’s cart. The WC_Customer class is constructed, and the read() method of the WC_Customer_Data_Store class is called to fetch the customer data.”What I think could be done:
I think we could check if the user exists in the site and bring the specific information related to him just for that specific website, because it seems information related to him and woocommerce from the whole network is what is being called. But I tried that and it broke the site. Tks! ??
- The topic ‘wc_load_cart() calling a lot of rows for wpms superadmin’ is closed to new replies.