[摘要] 新年新气象,有强迫症的人看到有新版本升级就手痒,手欠将所有可升级的插件都升级了一遍,哈哈,终于卡住了,刚升级了2个之后便出现500错误,控制台无法打开,wordpress 日志出现了Call to undefined function bws_general_menu() 这样的错误,看了下前端页面并不受影响,下面是两则wp升级失败的情况以及如何修复。
出问题后,先看了下日志:
2018/01/04 16:23:21 [error] 23301#0: *26030 FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to undefined function bws_general_menu() in /path/wordpress/wp-content/plugins/relevant/related-posts-plugin.php on line 34 PHP message: PHP Stack trace: PHP message: PHP 1. {main}() /path/wordpress/wp-admin/index.php:0 PHP message: PHP 2. require_once() /path/wordpress/wp-admin/index.php:10 PHP message: PHP 3. require() /path/wordpress/wp-admin/admin.php:140 PHP message: PHP 4. require_once() /path/wordpress/wp-admin/menu.php:286 PHP message: PHP 5. do_action() /path/wordpress/wp-admin/includes/menu.php:149 PHP message: PHP 6. WP_Hook->do_action() /path/wordpress/wp-includes/plugin.php:453 PHP message: PHP 7. WP_Hook->apply_filters() /path/wordpress/wp-includes/class-wp-hook.php:310 PHP message: PHP 8. call_user_func_array:{/path/wordpress/wp-includes/class-wp-hook.php:286}() /path/wordpress/wp-includes/class-wp-hook.php:286 PHP message: PHP 9. add_rltdpstsplgn_admin_menu() /path/wordpress/wp-includes/class-wp-hook.php:286" while reading response header from upstream, client: 172.68.133.199, server: sudops.com, request: "GET /wp-admin/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.sudops.com", referrer: "https://www.sudops.com/"
查了下bws_general_menu报错的地方,是出现在relevant这样一个插件。
# grep -r bws_general_menu * wp-content/plugins/relevant/bws_menu/bws_functions.php: bws_general_menu(); wp-content/plugins/relevant/bws_menu/bws_functions.php:if ( ! function_exists ( 'bws_general_menu' ) ) { wp-content/plugins/relevant/bws_menu/bws_functions.php: function bws_general_menu() { wp-content/plugins/relevant/bws_menu/bws_functions.php: global $menu, $bws_general_menu_exist; wp-content/plugins/relevant/bws_menu/bws_functions.php: if ( ! $bws_general_menu_exist ) { wp-content/plugins/relevant/bws_menu/bws_functions.php: /* we check also menu exist in global array as in old plugins $bws_general_menu_exist variable not exist */ wp-content/plugins/relevant/bws_menu/bws_functions.php: $bws_general_menu_exist = true; wp-content/plugins/relevant/bws_menu/bws_functions.php: $bws_general_menu_exist = true; wp-content/plugins/relevant/related-posts-plugin.php: bws_general_menu();
这样就好办了,最简单的办法就是进入到wp-content/plugins/目录,将有问题的插件移走,然后刷新 wordpress 页面即可。这个办法同样适用于 wordpress 的模板,如果因为某个模板导致页面无法打开也可以将模板删除或者移走,这方法百试不爽!
前两天升级的时候也出现了一次正在例行维护,请一分钟后回来的提示
解决方法是进入到发布目录,找到 .maintenance 文件,将其删除即可。