Skip to content

Commit d19ca3f

Browse files
author
zhaoxiang
committed
modified 升级ThinkPHP版本至5.0.23
1 parent d269482 commit d19ca3f

31 files changed

Lines changed: 819 additions & 367 deletions

thinkphp/.gitignore

100644100755
File mode changed.

thinkphp/.htaccess

100644100755
File mode changed.

thinkphp/.travis.yml

100644100755
File mode changed.

thinkphp/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// | Author: liu21st <liu21st@gmail.com>
1010
// +----------------------------------------------------------------------
1111

12-
define('THINK_VERSION', '5.0.19');
12+
define('THINK_VERSION', '5.0.23');
1313
define('THINK_START_TIME', microtime(true));
1414
define('THINK_START_MEM', memory_get_usage());
1515
define('EXT', '.php');

thinkphp/lang/zh-cn.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务',
4949
'fields not exists' => '数据表字段不存在',
5050
'where express error' => '查询表达式错误',
51+
'not support data' => '不支持的数据表达式',
5152
'no data to update' => '没有任何数据需要更新',
5253
'miss data to insert' => '缺少需要写入的数据',
5354
'miss complex primary data' => '缺少复合主键数据',

thinkphp/library/think/App.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ public static function module($result, $config, $convert = null)
551551

552552
// 获取控制器名
553553
$controller = strip_tags($result[1] ?: $config['default_controller']);
554+
555+
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
556+
throw new HttpException(404, 'controller not exists:' . $controller);
557+
}
558+
554559
$controller = $convert ? strtolower($controller) : $controller;
555560

556561
// 获取操作名

thinkphp/library/think/Log.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static function save()
176176
}
177177
}
178178

179-
if ($result = self::$driver->save($log)) {
179+
if ($result = self::$driver->save($log, true)) {
180180
self::$log = [];
181181
}
182182

@@ -211,7 +211,7 @@ public static function write($msg, $type = 'log', $force = false)
211211
is_null(self::$driver) && self::init(Config::get('log'));
212212

213213
// 写入日志
214-
if ($result = self::$driver->save($log)) {
214+
if ($result = self::$driver->save($log, false)) {
215215
self::$log = [];
216216
}
217217

thinkphp/library/think/Model.php

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
9494
protected $type = [];
9595
// 是否为更新数据
9696
protected $isUpdate = false;
97+
// 是否使用Replace
98+
protected $replace = false;
9799
// 是否强制更新所有数据
98100
protected $force = false;
99101
// 更新条件
@@ -1013,6 +1015,18 @@ protected function isPk($key)
10131015
return false;
10141016
}
10151017

1018+
/**
1019+
* 新增数据是否使用Replace
1020+
* @access public
1021+
* @param bool $replace
1022+
* @return $this
1023+
*/
1024+
public function replace($replace = true)
1025+
{
1026+
$this->replace = $replace;
1027+
return $this;
1028+
}
1029+
10161030
/**
10171031
* 保存当前数据对象
10181032
* @access public
@@ -1028,19 +1042,19 @@ public function save($data = [], $where = [], $sequence = null)
10281042
$data = [];
10291043
}
10301044

1031-
if (!empty($data)) {
1032-
// 数据自动验证
1033-
if (!$this->validateData($data)) {
1034-
return false;
1035-
}
1036-
// 数据对象赋值
1037-
foreach ($data as $key => $value) {
1038-
$this->setAttr($key, $value, $data);
1039-
}
1040-
if (!empty($where)) {
1041-
$this->isUpdate = true;
1042-
$this->updateWhere = $where;
1043-
}
1045+
// 数据自动验证
1046+
if (!$this->validateData($data)) {
1047+
return false;
1048+
}
1049+
1050+
// 数据对象赋值
1051+
foreach ($data as $key => $value) {
1052+
$this->setAttr($key, $value, $data);
1053+
}
1054+
1055+
if (!empty($where)) {
1056+
$this->isUpdate = true;
1057+
$this->updateWhere = $where;
10441058
}
10451059

10461060
// 自动关联写入
@@ -1163,9 +1177,9 @@ public function save($data = [], $where = [], $sequence = null)
11631177
// 检测字段
11641178
$allowFields = $this->checkAllowField(array_merge($this->auto, $this->insert));
11651179
if (!empty($allowFields)) {
1166-
$result = $this->getQuery()->strict(false)->field($allowFields)->insert($this->data, false, false, $sequence);
1180+
$result = $this->getQuery()->strict(false)->field($allowFields)->insert($this->data, $this->replace, false, $sequence);
11671181
} else {
1168-
$result = $this->getQuery()->insert($this->data, false, false, $sequence);
1182+
$result = $this->getQuery()->insert($this->data, $this->replace, false, $sequence);
11691183
}
11701184

11711185
// 获取自动增长主键

0 commit comments

Comments
 (0)