diff --git a/convention.php b/convention.php index a35ac0b9..c66ef583 100644 --- a/convention.php +++ b/convention.php @@ -203,6 +203,8 @@ return [ 'type' => '', // 是否自动开启 SESSION 'auto_start' => true, + 'httponly' => true, + 'secure' => true, ], // +---------------------------------------------------------------------- diff --git a/library/think/Console.php b/library/think/Console.php index 233489b5..1d97ab2b 100644 --- a/library/think/Console.php +++ b/library/think/Console.php @@ -88,18 +88,19 @@ class Console } /** - * @param $command - * @param array $parameters + * @param $command + * @param array $parameters + * @param string $driver * @return Output|Buffer */ - public static function call($command, array $parameters = []) + public static function call($command, array $parameters = [], $driver = 'buffer') { $console = self::init(false); array_unshift($parameters, $command); $input = new Input($parameters); - $output = new Output('buffer'); + $output = new Output($driver); $console->setCatchExceptions(false); $console->find($command)->run($input, $output); diff --git a/library/think/Model.php b/library/think/Model.php index b520f801..0491e551 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -438,7 +438,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 类型转换 $value = $this->readTransform($value, $this->type[$name]); } elseif (in_array($name, [$this->createTime, $this->updateTime])) { - $value = $this->formatDateTime($value, $this->dateFormat); + if (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp), ['datetime', 'date', 'timestamp'])) { + $value = $this->formatDateTime(strtotime($value), $this->dateFormat); + } else { + $value = $this->formatDateTime($value, $this->dateFormat); + } } elseif ($notFound) { $method = Loader::parseName($name, 1, false); if (method_exists($this, $method) && $this->$method() instanceof Relation) { @@ -724,7 +728,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $this->autoCompleteData($this->auto); // 自动写入更新时间 - if ($this->autoWriteTimestamp && $this->updateTime && !isset($this->data[$this->updateTime])) { + if ($this->autoWriteTimestamp && $this->updateTime && (empty($this->change) || !in_array($this->updateTime, $this->change))) { $this->setAttr($this->updateTime, null); } @@ -781,7 +785,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $this->autoCompleteData($this->insert); // 自动写入创建时间 - if ($this->autoWriteTimestamp && $this->createTime && !isset($this->data[$this->createTime])) { + if ($this->autoWriteTimestamp && $this->createTime && (empty($this->change) || !in_array($this->createTime, $this->change))) { $this->setAttr($this->createTime, null); } diff --git a/library/think/Route.php b/library/think/Route.php index 4f08e911..1629d636 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1097,7 +1097,7 @@ class Route * 绑定到模块/控制器 * @access public * @param string $url URL地址 - * @param string $class 控制器类名(带命名空间) + * @param string $controller 控制器类名(带命名空间) * @param string $depr URL分隔符 * @return array */ diff --git a/library/think/Session.php b/library/think/Session.php index 48f23caa..35726220 100644 --- a/library/think/Session.php +++ b/library/think/Session.php @@ -77,7 +77,12 @@ class Session ini_set('session.gc_maxlifetime', $config['expire']); ini_set('session.cookie_lifetime', $config['expire']); } - + if (isset($config['secure'])) { + ini_set('session.cookie_secure', $config['secure']); + } + if (isset($config['httponly'])) { + ini_set('session.cookie_httponly', $config['httponly']); + } if (isset($config['use_cookies'])) { ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0); } diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index 6f52693b..dba02c3e 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -21,7 +21,7 @@ class File extends Driver { protected $options = [ 'expire' => 0, - 'cache_subdir' => false, + 'cache_subdir' => true, 'prefix' => '', 'path' => CACHE_PATH, 'data_compress' => false, diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index 580dd10d..4e18f812 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -95,6 +95,8 @@ abstract class Connection 'slave_no' => '', // 是否严格检查字段是否存在 'fields_strict' => true, + // 数据返回类型 + 'result_type' => PDO::FETCH_ASSOC, // 数据集返回类型 'resultset_type' => 'array', // 自动写入时间戳字段 @@ -272,6 +274,10 @@ abstract class Connection if (isset($config['resultset_type'])) { $this->resultSetType = $config['resultset_type']; } + // 数据返回类型 + if (isset($config['result_type'])) { + $this->fetchType = $config['result_type']; + } try { if (empty($config['dsn'])) { $config['dsn'] = $this->parseDsn($config); @@ -326,6 +332,10 @@ abstract class Connection * @param array $bind 参数绑定 * @param bool $master 是否在主服务器读操作 * @param bool $class 是否返回PDO对象 + * @param string $sql sql指令 + * @param array $bind 参数绑定 + * @param boolean $master 是否在主服务器读操作 + * @param bool $pdo 是否返回PDO对象 * @return mixed * @throws BindParamException * @throws PDOException @@ -369,7 +379,7 @@ abstract class Connection // 调试结束 $this->debug(false); // 返回结果集 - return $this->getResult($class, $procedure); + return $this->getResult($pdo, $procedure); } catch (\PDOException $e) { throw new PDOException($e, $this->config, $this->getLastsql()); } diff --git a/library/think/model/relation/BelongsToMany.php b/library/think/model/relation/BelongsToMany.php index bbab3714..428620a2 100644 --- a/library/think/model/relation/BelongsToMany.php +++ b/library/think/model/relation/BelongsToMany.php @@ -308,7 +308,7 @@ class BelongsToMany extends Relation * @param bool $relationDel 是否同时删除关联表数据 * @return integer */ - public function detach($data, $relationDel = false) + public function detach($data = null, $relationDel = false) { if (is_array($data)) { $id = $data; diff --git a/library/think/template/taglib/Cx.php b/library/think/template/taglib/Cx.php index 8132c178..1a23c764 100644 --- a/library/think/template/taglib/Cx.php +++ b/library/think/template/taglib/Cx.php @@ -431,7 +431,7 @@ class Cx extends Taglib { $name = $tag['name']; $name = $this->autoBuildVar($name); - $parseStr = 'isEmpty())): ?>' . $content . ''; + $parseStr = 'isEmpty())): ?>' . $content . ''; return $parseStr; } @@ -448,7 +448,7 @@ class Cx extends Taglib { $name = $tag['name']; $name = $this->autoBuildVar($name); - $parseStr = 'isEmpty()))): ?>' . $content . ''; + $parseStr = 'isEmpty()))): ?>' . $content . ''; return $parseStr; } diff --git a/tests/thinkphp/library/think/template/taglib/cxTest.php b/tests/thinkphp/library/think/template/taglib/cxTest.php index 54a8a931..c1c67413 100644 --- a/tests/thinkphp/library/think/template/taglib/cxTest.php +++ b/tests/thinkphp/library/think/template/taglib/cxTest.php @@ -389,7 +389,7 @@ default {/empty} EOF; $data = <<isEmpty())): ?> +isEmpty())): ?> default EOF; @@ -402,7 +402,7 @@ default {/notempty} EOF; $data = <<isEmpty()))): ?> +isEmpty()))): ?> default EOF; @@ -538,13 +538,13 @@ EOF; public function testUrl() { $template = new template(); - $content = <<display($content); $this->expectOutputString(\think\Url::build('Index/index')); } - + public function testFunction() { $template = new template();