You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决WordPress中无效的NOT IN() SQL查询问题?

WordPress后台页面/产品列表无法加载问题排查记录

症状

  • WordPress后台菜单中无法查看任何页面或产品列表,但前端通过网页链接可正常访问这些页面和产品

问题排查

  • 通过Query Monitor检测到SQL语法错误:无效的空数组参数传入NOT IN()语句,生成了AND wp_posts.post_author NOT IN ()的错误片段,触发MariaDB报错:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax
  • 调用栈指向WooCommerce或WooCommerce Payments插件,但禁用这些插件及多数其他插件后问题仍存在;禁用i-excel主题后问题消失,但需保留该主题使用,且问题为突发,此前未进行任何系统更新

更新记录

  1. 曾推测问题源于WordPress核心从5.9.2自动更新至6.3.2,使用降级工具恢复旧版本未解决;随后更新WordPress及所有插件,错误仍存在但出现频率降低,网站可正常运行
  2. 追踪调用栈至get_option('wp_custom_filters');,尝试通过界面或数据库修改该选项内容,但未找到相关资料。相关函数逻辑显示无设置时应返回null,理论上应生成wp_posts.post_author NOT IN (null)的合法语句,但实际执行的却是空参数的wp_posts.post_author NOT IN ()

附录

错误SQL查询语句(Query Monitor截取最短版本)

SELECT wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = 'shop_subscription'
AND wp_posts.post_author NOT IN ()
ORDER BY wp_posts.post_date DESC
LIMIT 0, 1

对应调用栈

WP_Query->get_posts()
wp-includes/class-wp-query.php:3219
WP_Query->query()
wp-includes/class-wp-query.php:3800
WP_Query->__construct()
wp-includes/class-wp-query.php:3932
WC_Order_Data_Store_CPT->query()
wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php:965
WC_Data_Store->__call()
wp-content/plugins/woocommerce/includes/class-wc-data-store.php:207
WC_Order_Query->get_orders()
wp-content/plugins/woocommerce/includes/class-wc-order-query.php:87
wc_get_orders()
wp-content/plugins/woocommerce/includes/wc-order-functions.php:66
wcs_do_subscriptions_exist()
wp-content/plugins/woocommerce-payments/vendor/woocommerce/subscriptions-core/wcs-functions.php:62
WC_Payments_Subscriptions_Empty_State_Manager->replace_subscriptions_empty_state()
wp-content/plugins/woocommerce-payments/includes/subscriptions/class-wc-payments-subscriptions-empty-state-manager.php:93
apply_filters('woocommerce_subscriptions_not_found_label')
wp-includes/plugin.php:205
WC_Subscriptions_Core_Plugin->register_order_types()
wp-content/plugins/woocommerce-payments/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-core-plugin.php:341
do_action('init')
wp-includes/plugin.php:517

内容的提问来源于stack exchange,提问作者Ádám Bukovinszki

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 00:45:05