使用搜索出现无效的UTF-8序列错误
-
wordpress 4.8.1版本,之前一直没有出现过此提示。
用了 wp-super-cache 后,在日志中发现有此错误。我将问题反映给 wp-super-cache 的作者,作者答复说这不是插件的问题,插件只是调用了系统日志。这是一个
json_encode(): Invalid UTF-8 sequence
错误的问题。附上插件作者的回答:Issues从日志中可以看出,这个问题是在使用搜索的时候发生的,经过我自己的测试,正常的中文,英文混输并没有重现该问题。而日志中记录的该错误的搜索内容应该是不正常的输入,不排除攻击行为。
那么这个问题是 wordpress 的 bug 吗?要如何解决这个问题。
错误日志如下:
2017/08/19 07:56:15 [error] 21178#0: *8407 FastCGI sent in stderr: "PHP message: PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in /XXXX.com/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 53 PHP message: WordPress数据库查询SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%?????o?��?��?a???%') OR (wp_posts.post_excerpt LIKE '%?????o?��?��?a???%') OR (wp_posts.post_content LIKE '%?????o?��?��?a???%'))) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_title LIKE '%?????o?��?��?a???%' DESC, wp_posts.post_date DESC LIMIT 0, 18时发生Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_unicode_520_ci,COERCIBLE) for operation 'like'错误,这是由require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts查询的。" while reading response header from upstream, client: 58.211.2.66, server: XXXX.com, request: "GET /?s=?????o?��?��?a??? HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock:", host: "www.XXXX.com", referrer: "http://www.XXXX.com/category/html/"
2017/08/19 07:56:23 [error] 21179#0: *8412 FastCGI sent in stderr: "PHP message: PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in /XXXX.com/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 53 PHP message: WordPress数据库查询SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%?��?��?a???%') OR (wp_posts.post_excerpt LIKE '%?��?��?a???%') OR (wp_posts.post_content LIKE '%?��?��?a???%'))) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_title LIKE '%?��?��?a???%' DESC, wp_posts.post_date DESC LIMIT 0, 18时发生Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_unicode_520_ci,COERCIBLE) for operation 'like'错误,这是由require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts查询的。" while reading response header from upstream, client: 58.211.2.36, server: XXXX.com, request: "GET /?s=?��?��?a??? HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-cgi.sock:", host: "www.XXXX.com", referrer: "http://www.XXXX.com/?s=%E6%89%8B%E6%9C%BA%E5%AF%BC%E8%88%AA%E6%9D%A1"
- 话题 ‘使用搜索出现无效的UTF-8序列错误’不再接受新回复。