From 458cd825075a1fe18d823e48527be115ce544088 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 25 May 2016 16:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E9=A1=B5=E9=9D=A2trace?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Response.php | 9 +++++++-- library/think/log/driver/Trace.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/library/think/Response.php b/library/think/Response.php index eb70ad8f..d531979f 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -53,8 +53,11 @@ class Response if (isset($this->contentTypes[$this->type])) { $this->contentType($this->contentTypes[$this->type]); } - - $this->options = array_merge($this->options, $options); + if(!empty($options)){ + $this->options = array_merge($this->options, $options); + } + // 方便获取某个类型的实例 + self::$instance[$this->type] = $this; } /** @@ -97,6 +100,8 @@ class Response $data = call_user_func_array($this->transform, [$data]); } + define('RESPONSE_TYPE',$this->type); + // 处理输出数据 $data = $this->output($data); diff --git a/library/think/log/driver/Trace.php b/library/think/log/driver/Trace.php index d0501b2f..6b160042 100644 --- a/library/think/log/driver/Trace.php +++ b/library/think/log/driver/Trace.php @@ -41,7 +41,7 @@ class Trace */ public function save(array $log = []) { - if (IS_AJAX || IS_CLI || IS_API || 'html' != Config::get('default_return_type')) { + if (IS_AJAX || IS_CLI || IS_API || 'html' != RESPONSE_TYPE) { // ajax cli api方式下不输出 return false; }