瓜奇用了2天了,但是发现个问题,社区二级回复的评论一刷新就没有了,自己debug了好几天,今天尝试用calude Ai分析了一下错误日志,终于找到了问题原因,并用calude提供的解决方案解决了问题。
先说答案,主要原因是MySQL 5.7 不支持递归查询语法 WITH RECURSIVE
,导致获取多层评论回复的SQL执行失败,所以二级回复无法显示。
解决方案就是MySQL升级到8.0版本。
下面是Claude AI协助我解决问题的全过程
这一段是我抛给Claude AI的问题:
这是wp的bug日志,帮我分析下二级回复不显示的原因:
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
' at line 1 for query
WITH RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
FROM api_comments
WHERE comment_parent = 21
AND comment_approved = 1
UNION ALL
SELECT c.comment_ID, c.comment_parent
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE c.comment_approved = 1
)
SELECT comment_ID
FROM comment_tree
WHERE comment_ID > 0
ORDER BY comment_ID
LIMIT 6
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID
' at line 2 for query
SELECT COUNT(*) FROM (
WITH RECURSIVE comment_tree AS (
SELECT comment_ID
FROM api_comments
WHERE comment_parent = 21 AND (comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
UNION ALL
SELECT c.comment_ID
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE (c.comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
)
SELECT comment_ID FROM comment_tree
) as total
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_reply_count
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
' at line 1 for query
WITH RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
FROM api_comments
WHERE comment_parent = 20
AND comment_approved = 1
UNION ALL
SELECT c.comment_ID, c.comment_parent
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE c.comment_approved = 1
)
SELECT comment_ID
FROM comment_tree
WHERE comment_ID > 0
ORDER BY comment_ID
LIMIT 6
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID
' at line 2 for query
SELECT COUNT(*) FROM (
WITH RECURSIVE comment_tree AS (
SELECT comment_ID
FROM api_comments
WHERE comment_parent = 20 AND (comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
UNION ALL
SELECT c.comment_ID
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE (c.comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
)
SELECT comment_ID FROM comment_tree
) as total
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_reply_count
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
' at line 1 for query
WITH RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
FROM api_comments
WHERE comment_parent = 19
AND comment_approved = 1
UNION ALL
SELECT c.comment_ID, c.comment_parent
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE c.comment_approved = 1
)
SELECT comment_ID
FROM comment_tree
WHERE comment_ID > 0
ORDER BY comment_ID
LIMIT 6
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID
' at line 2 for query
SELECT COUNT(*) FROM (
WITH RECURSIVE comment_tree AS (
SELECT comment_ID
FROM api_comments
WHERE comment_parent = 19 AND (comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
UNION ALL
SELECT c.comment_ID
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE (c.comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
)
SELECT comment_ID FROM comment_tree
) as total
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_reply_count
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
' at line 1 for query
WITH RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
FROM api_comments
WHERE comment_parent = 16
AND comment_approved = 1
UNION ALL
SELECT c.comment_ID, c.comment_parent
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE c.comment_approved = 1
)
SELECT comment_ID
FROM comment_tree
WHERE comment_ID > 0
ORDER BY comment_ID
LIMIT 6
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn
[15-Oct-2025 17:57:53 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
SELECT comment_ID
' at line 2 for query
SELECT COUNT(*) FROM (
WITH RECURSIVE comment_tree AS (
SELECT comment_ID
FROM api_comments
WHERE comment_parent = 16 AND (comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
UNION ALL
SELECT c.comment_ID
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE (c.comment_approved = 1 OR (comment_approved = '0' AND user_id = 1))
)
SELECT comment_ID FROM comment_tree
) as total
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, WPGraphQL\Router::resolve_http_request, WPGraphQL\Router::process_http_request, WPGraphQL\Request->execute_http, GraphQL\Server\StandardServer->executeRequest, GraphQL\Server\Helper->executeOperation, GraphQL\Server\Helper->promiseToExecuteOperation, GraphQL\GraphQL::promiseToExecute, GraphQL\Executor\Executor::promiseToExecute, GraphQL\Executor\ReferenceExecutor->doExecute, GraphQL\Executor\ReferenceExecutor->executeOperation, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Main->GUAQI\GraphQL\{closure}, GUAQI\GraphQL\LoginData->get_login_data, do_graphql_request, graphql, WPGraphQL\Request->execute, GraphQL\GraphQL::executeQuery, GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait, GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue, GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}, GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeListValue, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->completeValueCatchingError, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeValue, GraphQL\Executor\ReferenceExecutor->completeObjectValue, GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields, GraphQL\Executor\ReferenceExecutor->executeFields, GraphQL\Executor\ReferenceExecutor->resolveField, GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError, WPGraphQL\Utils\InstrumentSchema::WPGraphQL\Utils\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->GUAQI\GraphQL\Querys\Common\Single\{closure}, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_fn, GUAQI\GraphQL\Querys\Common\Single\Comment->comment_reply_count
下面是Calude的原因分析及解决方案
根据您提供的错误日志,我可以明确分析出二级回复不显示的原因:
问题根源
MySQL版本不支持递归CTE(Common Table Expression)语法
错误信息显示:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RECURSIVE comment_tree AS (
具体原因
- 使用了
WITH RECURSIVE
语法:代码中使用递归查询来获取评论树结构(父评论及其所有子评论) - MySQL版本过低:
WITH RECURSIVE
是 MySQL 8.0+ 才支持的特性。如果您的MySQL版本是 5.7 或更早版本,就会出现此语法错误 - 查询失败导致数据缺失:因为SQL执行失败,无法获取二级回复数据,所以前端自然显示不出来
解决方案
方案1:升级MySQL(推荐)
升级到 MySQL 8.0 或更高版本,这是最根本的解决方法
方案2:修改查询逻辑
如果无法升级MySQL,需要修改代码中的递归查询,改用传统的查询方式:
php
// 替代递归CTE的传统方法
// 1. 先查询直接子评论
SELECT comment_ID FROM api_comments
WHERE comment_parent = 21
AND comment_approved = 1
ORDER BY comment_ID
LIMIT 6
// 2. 如需更深层级,分多次查询或使用JOIN
方案3:检查插件兼容性
这个错误来自 GUAQI\GraphQL
插件的评论查询功能。您可以:
- 联系插件开发者,询问是否有兼容低版本MySQL的选项
- 查看插件设置中是否有关于数据库兼容性的配置
- 更新插件到最新版本(可能已修复此问题)
验证MySQL版本
在WordPress数据库中执行:
sql
SELECT VERSION();
如果版本号小于 8.0,就需要考虑升级或使用替代方案。Retry
Claude does not have the ability to run the code it generates yet.
我回复:我用的MySQL 5.7
确认了!问题就是这个:MySQL 5.7 不支持 WITH RECURSIVE
语法,这个特性从 MySQL 8.0 才开始支持。
解决方案
方案1:升级到 MySQL 8.0+(最佳方案)
优点:彻底解决问题,且获得更好的性能和新特性
操作步骤:
- 备份所有数据库数据
- 联系服务器管理员或主机商升级MySQL
- 测试网站功能是否正常
⚠️ 注意:升级前务必完整备份数据库!
方案2:修改插件代码(临时方案)
如果暂时无法升级MySQL,需要修改 GUAQI\GraphQL
插件的评论查询代码。
找到文件(大概路径):
wp-content/plugins/guaqi-graphql/src/Querys/Common/Single/Comment.php
查找并修改递归查询部分,将:
php
// 原来的递归CTE查询
WITH RECURSIVE comment_tree AS (
SELECT comment_ID, comment_parent
FROM api_comments
WHERE comment_parent = {$parent_id}
AND comment_approved = 1
UNION ALL
SELECT c.comment_ID, c.comment_parent
FROM api_comments c
INNER JOIN comment_tree ct ON c.comment_parent = ct.comment_ID
WHERE c.comment_approved = 1
)
SELECT comment_ID FROM comment_tree
改为传统查询方式:
php
// MySQL 5.7 兼容的查询(仅获取直接子评论)
SELECT comment_ID, comment_parent
FROM api_comments
WHERE comment_parent = {$parent_id}
AND comment_approved = 1
ORDER BY comment_ID
LIMIT 6
缺点:这样只能获取一层子评论,如果需要多层嵌套,需要在PHP层面递归查询。
方案3:联系插件开发者
- 访问 GUAQI GraphQL 插件的支持页面
- 报告这个MySQL 5.7兼容性问题
- 询问是否有配置选项可以切换查询模式
推荐做法
我强烈建议选择方案1(升级MySQL 8.0),原因:
- ✅ MySQL 5.7 已于2023年10月停止官方支持,存在安全风险
- ✅ MySQL 8.0 性能更好,功能更强
- ✅ 一劳永逸解决问题,避免未来其他插件也遇到类似问题
- ✅ 现代WordPress插件越来越多使用新特性
如果您是使用虚拟主机,可以联系主机商客服协助升级;如果是云服务器,建议先在测试环境完整备份后再升级。