配置文件异常处理使用闭包,缓存生成bug

浏览:424 发布日期:2018/08/13
5.0.0 - 普通 - 未处理
版本:5.0.20
config.php中配置exception_handle使用闭包,生成配置缓存optimize:config后,由于使用闭包导致生成的init.php有问题,然后就悲剧了。

生成init.php直接使用var_dump会存在问题。估计那几个缓存生成都有类似的问题。

thinkphp/library/think/console/command/optimize/Config.php 90行附近

// 加载公共文件
if (is_file($path . 'common' . EXT)) {
$content .= substr(php_strip_whitespace($path . 'common' . EXT), 5) . PHP_EOL;
}

$content .= '\think\Config::set(' . var_export(ThinkConfig::get(), true) . ');';
return $content;


config.php中使用闭包

'exception_handle' => function (Exception $e) {
// 请求异常
if($e instanceof \think\exception\HttpException){
trace($e->getMessage(),'error');
}
},
评论(
后面还有条评论,点击查看>>