From f3a60a523e7fcc32be986e19947bc1a39b73c46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E9=99=86=E5=BD=AC?= Date: Thu, 23 Dec 2021 14:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AB=AF=E5=8F=A3=E4=B8=8D?= =?UTF-8?q?=E5=A4=9F=E7=94=A8=E6=97=B6=EF=BC=8C=E5=9C=A8debug=3Dfalse?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8Bredis=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E5=B0=86=E5=BE=88=E8=AF=A6=E7=BB=86=E7=9A=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/Server.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Http/Server.php b/src/Http/Server.php index d2327b9..f502110 100644 --- a/src/Http/Server.php +++ b/src/Http/Server.php @@ -23,6 +23,7 @@ use Discuz\Foundation\Application; use Discuz\Foundation\SiteApp; use Discuz\Http\Middleware\RequestHandler; use Illuminate\Database\QueryException; +use Illuminate\Support\Str; use Laminas\Diactoros\Response; use Laminas\Diactoros\ServerRequest; use Laminas\Diactoros\ServerRequestFactory; @@ -123,6 +124,20 @@ class Server extends SiteApp $line = $error->getLine(); $type = get_class($error); $this->app->make('log')->error($error); + /** + * 2021-12-23 11:43 ys wulubin + * 为了解决端口不够用时,在debug=false的情况下redis报错将很详细的信息暴露出来 + */ + if (!app()->config('debug')) { + $data = json_encode([ + 'Code' => -5001, + 'Message' => '网络错误', + 'Data' => [], + 'requestId' => Str::uuid(), + 'requestTime' => date('Y-m-d H:i:s') + ],JSON_UNESCAPED_UNICODE); + return $data; + } $trace = $error->getTraceAsString(); return << -- Gitee