Explorar o código

Fixed:异常的情况下,通过render渲染存在多次渲染的情况。

zjh hai 4 meses
pai
achega
8a115a749b
Modificáronse 4 ficheiros con 7 adicións e 32 borrados
  1. 5 2
      src/Base/Response.php
  2. 0 28
      src/Driver/Entity/Base.php
  3. 1 1
      src/Exceptions/Error.php
  4. 1 1
      src/Qii.php

+ 5 - 2
src/Base/Response.php

@@ -209,10 +209,12 @@ class Response
             switch ($this->data['format']) {
                 case self::FORMAT_JSON:
                     $this->setHeader('Status', $code);
-                    $this->setHeader('Content-Type', 'text/json');
+                    $this->setHeader('Content-Type', 'application/json');
                     $this->sendHeaders();
                     $headerIsSent = true;
                     echo json_encode($this->data['body'], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
+                    //clear body
+                    unset($this->data['body']);
                     break;
                 default:
                     $this->setHeader('Status', $code);
@@ -231,7 +233,8 @@ class Response
                             $body = Response::$render->fetch($this->data['body']['tpl']);
                         }
                     }
-                    //$this->setBody($body);
+                    //clear body
+                    unset($this->data['body']);
                     echo(IS_CLI ? (new Cli())->stdout($body) : $body);
                     break;
             }

+ 0 - 28
src/Driver/Entity/Base.php

@@ -72,13 +72,6 @@ class Base {
      */
     private $lastInsertID;
 
-    /**
-     * 动态创建属性
-     *
-     * @var array
-     */
-    private $setter = [];
-
     /** 表名
      *
      * @var null
@@ -100,27 +93,6 @@ class Base {
         $this->privateKeys = null;
         $this->exclude = [];
     }
-
-    /**
-     * setter
-     * @param string $name key
-     * @param mixed $value value
-     * @return void
-     */
-    public function __set($name, $value) {
-        $this->setter[$name] = $value;
-    }
-    /**
-     * getter
-     * @param $name
-     * @return mixed|null
-     */
-    public function __get($name) {
-        if(isset($this->setter[$name])) {
-            return $this->setter[$name];
-        }
-        return null;
-    }
     /**
      * 默认值,仅在新增数据的时候支持,更新不支持
      *

+ 1 - 1
src/Exceptions/Error.php

@@ -86,7 +86,7 @@ class Error
      * @param string $args ...
      * @return bool
      */
-    public static function setError($condition, $line = 0, $code, $args = null, $msg = null)
+    public static function setError($condition, $line = 0, $code = 500, $args = null, $msg = null)
     {
         if ($condition) {
             return false;

+ 1 - 1
src/Qii.php

@@ -149,7 +149,7 @@ class Qii extends Application
 
     /**
      * 错误设置,如果满足给定的条件就直接返回false,否则在设置了错误页面的情况下返回true
-     * 如果出错后要终止的话,需要自行处理,此方法不停止不执行
+     * 如果出错后要终止的话,需要自行处理,此方法不停止不执行
      *
      * @param Bool $condition
      * @param int $line 出错的行数,这样以便轻松定位错误