我不断遇到如下错误:
[29-Dec-2015 03:06:14 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query DELETE FROM wp_options WHERE option_name LIKE \'\\\\_transient\\\\_%1451358373\' ORDER BY option_id LIMIT 1000; made by require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), do_action(\'template_redirect\'), call_user_func_array, wc_custom_redirect_after_purchase, WC_Abstract_Order->update_status, wc_delete_shop_order_transients, WC_Cache_Helper::get_transient_version, WC_Cache_Helper::delete_version_transients
[29-Dec-2015 03:07:07 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query DELETE FROM wp_options WHERE option_name LIKE \'_transient_wpseo_sitemap_cache_shop_order_%\' OR option_name LIKE \'_transient_timeout_wpseo_sitemap_cache_shop_order_%\' made by require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), do_action(\'template_redirect\'), call_user_func_array, WC_AJAX::do_wc_ajax, do_action(\'wc_ajax_checkout\'), call_user_func_array, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Abstract_Order->payment_complete, WC_Abstract_Order->update_status, WC_Abstract_Order->add_order_note, wp_insert_comment, wp_update_comment_count, wp_update_comment_count_now, clean_post_cache, clean_object_term_cache, do_action(\'clean_object_term_cache\'), call_user_func_array, wpseo_invalidate_sitemap_cache_terms, wpseo_invalidate_sitemap_cache, WPSEO_Utils::clear_sitemap_cache
[29-Dec-2015 03:07:07 UTC] WordPress database error Deadlock found when trying to get lock; try restarting transaction for query DELETE FROM wp_options WHERE option_name LIKE \'\\\\_transient\\\\_%1451358425\' ORDER BY option_id LIMIT 1000; made by require(\'wp-blog-header.php\'), require_once(\'wp-includes/template-loader.php\'), do_action(\'template_redirect\'), call_user_func_array, WC_AJAX::do_wc_ajax, do_action(\'wc_ajax_checkout\'), call_user_func_array, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Abstract_Order->payment_complete, WC_Abstract_Order->update_status, wc_delete_shop_order_transients, WC_Cache_Helper::get_transient_version, WC_Cache_Helper::delete_version_transients
我想这是因为我在函数中有以下函数。php:
add_action( \'template_redirect\', \'wc_custom_redirect_after_purchase\' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars[\'order-received\'] ) ) {
global $wpdb;
$email = $_COOKIE[\'xxx_email\'] ? $_COOKIE[\'xxx_email\'] : $_SESSION[\'xxx_email\'];
$mylink = $wpdb->get_row("SELECT email FROM xxx WHERE email = \'$email\'");
if (!$mylink->email) {
wp_redirect( \'http://xxx/abc/\' );
exit;
}
$order_id = absint( $wp->query_vars[\'order-received\'] );
$order = new WC_Order($order_id);
if (!empty($order)) {
$order->update_status( \'completed\' );
} else {
wp_redirect( \'http://xxx/xyz/\' );
exit;
}
}
}
基本上,该函数的作用是查看用于下订单的电子邮件地址是否已经在我们的数据库中。如果它不在我们的数据中,那么用户将被重定向到一个通用页面,告诉他们确认他们的电子邮件。如果在我们的数据库中,订单状态将更新为“已完成”,用户将被发送到常规WooCommerce感谢页面。
你知道为什么会抛出错误以及如何修复吗?需要注意的是,该功能通常有效;这是一个实时网站,并正在按应有的方式工作。然而,我经常在error\\u日志中看到上述错误。因此,似乎有一些事情间歇性地出错。知道吗?什么?
谢谢