今天在后台审帖时发现部分帖子提交后页面空白,操作无效,需要打开PHP报错信息了解原因,发现Discuz!官方似乎并未提供X3的Debug程序,网上别的方式试了也不行(末尾注),于是简单粗暴进行以下修改,成功查看到错误信息并解决问题。
1、打开PHP的 display_errors ;
2、打开 source/class/discuz/discuz_application.php ,查找:
if(empty($_config['debug']) || !file_exists(libfile('function/debug'))) {
define('DISCUZ_DEBUG', false);
error_reporting(0);
} elseif($_config['debug'] === 1 || $_config['debug'] === 2 || !empty($_REQUEST['debug']) && $_REQUEST['debug'] === $_config['debug']) {
define('DISCUZ_DEBUG', true);
error_reporting(E_ERROR);
if($_config['debug'] === 2) {
error_reporting(E_ALL);
}
} else {
define('DISCUZ_DEBUG', false);
error_reporting(0);
}
替换为:
define('DISCUZ_DEBUG', true);
error_reporting(E_ERROR);
错误排查完后,记得恢复以上代码和设置。
注:类似 https://blog.csdn.net/wz947324/article/details/80439621 的方法需要在URI中添加 ?debug=1 才能获得报错信息,但后台审核页面存在框架,比较麻烦。