thinkphp升级至5.0.24

This commit is contained in:
sugar1569 2019-01-23 09:05:02 +08:00
parent efa14d42fe
commit 045229fad6
11 changed files with 178 additions and 44 deletions

View File

@ -22,9 +22,11 @@
"topthink/think-image": "^1.0", "topthink/think-image": "^1.0",
"topthink/think-captcha": "1.*", "topthink/think-captcha": "1.*",
"overtrue/wechat": "^3.3", "overtrue/wechat": "^3.3",
"tp5er/tp5-databackup": "dev-master",
"xaboy/form-builder": "^1.2", "xaboy/form-builder": "^1.2",
"tp5er/tp5-databackup": "^1.0", "phpoffice/phpexcel": "^1.8",
"phpoffice/phpexcel": "^1.8" "topthink/think-helper": "^1.0",
"taskphp/taskphp": "dev-master"
}, },
"extra": { "extra": {
"think-path": "thinkphp" "think-path": "thinkphp"

110
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ae2e50326d8e83fd299c3350bb0f87d1", "content-hash": "ea77e5047084835254d437402863700f",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
@ -870,17 +870,60 @@
"time": "2016-09-14T18:37:20+00:00" "time": "2016-09-14T18:37:20+00:00"
}, },
{ {
"name": "topthink/framework", "name": "taskphp/taskphp",
"version": "v5.0.23", "version": "dev-master",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/framework.git", "url": "https://github.com/qq8044023/taskPHP.git",
"reference": "4cbc0b5e93314446243ebc7d5f005f9c32864737" "reference": "0faf4342887c14149273de84aaeb120aa9aa4c19"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/4cbc0b5e93314446243ebc7d5f005f9c32864737", "url": "https://api.github.com/repos/qq8044023/taskPHP/zipball/0faf4342887c14149273de84aaeb120aa9aa4c19",
"reference": "4cbc0b5e93314446243ebc7d5f005f9c32864737", "reference": "0faf4342887c14149273de84aaeb120aa9aa4c19",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
},
"type": "library",
"autoload": {
"psr-0": {
"taskphp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "cunzhang",
"email": "8044023@qq.com"
}
],
"description": "taskphp for PHP 5.6",
"homepage": "https://github.com/qq8044023/taskPHP",
"keywords": [
"phptask",
"task",
"taskphp",
"timePHP"
],
"time": "2018-11-07T02:59:53+00:00"
},
{
"name": "topthink/framework",
"version": "v5.0.24",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be",
"reference": "c255c22b2f5fa30f320ecf6c1d29f7740eb3e8be",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -918,7 +961,7 @@
"orm", "orm",
"thinkphp" "thinkphp"
], ],
"time": "2018-12-09T12:40:40+00:00" "time": "2019-01-11T08:04:58+00:00"
}, },
{ {
"name": "topthink/think-captcha", "name": "topthink/think-captcha",
@ -956,6 +999,42 @@
"description": "captcha package for thinkphp5", "description": "captcha package for thinkphp5",
"time": "2016-07-06T01:47:11+00:00" "time": "2016-07-06T01:47:11+00:00"
}, },
{
"name": "topthink/think-helper",
"version": "v1.0.7",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-helper.git",
"reference": "5f92178606c8ce131d36b37a57c58eb71e55f019"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-helper/zipball/5f92178606c8ce131d36b37a57c58eb71e55f019",
"reference": "5f92178606c8ce131d36b37a57c58eb71e55f019",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-4": {
"think\\helper\\": "src"
},
"files": [
"src/helper.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "yunwuxin",
"email": "448901948@qq.com"
}
],
"description": "The ThinkPHP5 Helper Package",
"time": "2018-10-05T00:43:21+00:00"
},
{ {
"name": "topthink/think-image", "name": "topthink/think-image",
"version": "v1.0.7", "version": "v1.0.7",
@ -1078,16 +1157,16 @@
}, },
{ {
"name": "tp5er/tp5-databackup", "name": "tp5er/tp5-databackup",
"version": "1.0.0", "version": "dev-master",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tp5er/tp5-databackup.git", "url": "https://github.com/tp5er/tp5-databackup.git",
"reference": "10abd4383cf78844e1c22584fd823ef1d18e75dc" "reference": "101477abe810fb91bad5c1304a93c5f461db6dc8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tp5er/tp5-databackup/zipball/10abd4383cf78844e1c22584fd823ef1d18e75dc", "url": "https://api.github.com/repos/tp5er/tp5-databackup/zipball/101477abe810fb91bad5c1304a93c5f461db6dc8",
"reference": "10abd4383cf78844e1c22584fd823ef1d18e75dc", "reference": "101477abe810fb91bad5c1304a93c5f461db6dc8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1110,7 +1189,7 @@
} }
], ],
"description": "Implement the database backup restore", "description": "Implement the database backup restore",
"time": "2017-12-29T05:36:58+00:00" "time": "2018-04-07T11:20:53+00:00"
}, },
{ {
"name": "xaboy/form-builder", "name": "xaboy/form-builder",
@ -1154,7 +1233,10 @@
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {
"tp5er/tp5-databackup": 20,
"taskphp/taskphp": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {

View File

@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
define('THINK_VERSION', '5.0.23'); define('THINK_VERSION', '5.0.24');
define('THINK_START_TIME', microtime(true)); define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage()); define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php'); define('EXT', '.php');

View File

@ -99,6 +99,16 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
return new static(array_keys($this->items)); return new static(array_keys($this->items));
} }
/**
* 返回数组中所有的值组成的新 Collection 实例
* @access public
* @return static
*/
public function values()
{
return new static(array_values($this->items));
}
/** /**
* 合并数组并返回一个新的 Collection 实例 * 合并数组并返回一个新的 Collection 实例
* @access public * @access public
@ -273,7 +283,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
$result = []; $result = [];
foreach ($this->items as $row) { foreach ($this->items as $row) {
$key = $value = null; $key = $value = null;
$keySet = $valueSet = false; $keySet = $valueSet = false;
if (null !== $indexKey && array_key_exists($indexKey, $row)) { if (null !== $indexKey && array_key_exists($indexKey, $row)) {
@ -309,7 +319,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
*/ */
public function sort(callable $callback = null) public function sort(callable $callback = null)
{ {
$items = $this->items; $items = $this->items;
$callback = $callback ?: function ($a, $b) { $callback = $callback ?: function ($a, $b) {
return $a == $b ? 0 : (($a < $b) ? -1 : 1); return $a == $b ? 0 : (($a < $b) ? -1 : 1);
}; };

View File

@ -1043,13 +1043,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
} }
// 数据自动验证 // 数据自动验证
if (!$this->validateData($data)) { if (!empty($data)) {
return false; if (!$this->validateData($data)) {
} return false;
}
// 数据对象赋值 // 数据对象赋值
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$this->setAttr($key, $value, $data); $this->setAttr($key, $value, $data);
}
} }
if (!empty($where)) { if (!empty($where)) {

View File

@ -415,7 +415,7 @@ class Request
foreach (Config::get('pathinfo_fetch') as $type) { foreach (Config::get('pathinfo_fetch') as $type) {
if (!empty($_SERVER[$type])) { if (!empty($_SERVER[$type])) {
$_SERVER['PATH_INFO'] = (0 === strpos($_SERVER[$type], $_SERVER['SCRIPT_NAME'])) ? $_SERVER['PATH_INFO'] = (0 === strpos($_SERVER[$type], $_SERVER['SCRIPT_NAME'])) ?
substr($_SERVER[$type], strlen($_SERVER['SCRIPT_NAME'])) : $_SERVER[$type]; substr($_SERVER[$type], strlen($_SERVER['SCRIPT_NAME'])) : $_SERVER[$type];
break; break;
} }
} }
@ -522,8 +522,14 @@ class Request
return $this->server('REQUEST_METHOD') ?: 'GET'; return $this->server('REQUEST_METHOD') ?: 'GET';
} elseif (!$this->method) { } elseif (!$this->method) {
if (isset($_POST[Config::get('var_method')])) { if (isset($_POST[Config::get('var_method')])) {
$this->method = strtoupper($_POST[Config::get('var_method')]); $method = strtoupper($_POST[Config::get('var_method')]);
$this->{$this->method}($_POST); if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) {
$this->method = $method;
$this->{$this->method}($_POST);
} else {
$this->method = 'POST';
}
unset($_POST[Config::get('var_method')]);
} elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
$this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
} else { } else {
@ -672,8 +678,8 @@ class Request
public function route($name = '', $default = null, $filter = '') public function route($name = '', $default = null, $filter = '')
{ {
if (is_array($name)) { if (is_array($name)) {
$this->param = []; $this->param = [];
$this->mergeParam = false; $this->mergeParam = false;
return $this->route = array_merge($this->route, $name); return $this->route = array_merge($this->route, $name);
} }
return $this->input($this->route, $name, $default, $filter); return $this->input($this->route, $name, $default, $filter);
@ -719,8 +725,8 @@ class Request
} }
} }
if (is_array($name)) { if (is_array($name)) {
$this->param = []; $this->param = [];
$this->mergeParam = false; $this->mergeParam = false;
return $this->post = array_merge($this->post, $name); return $this->post = array_merge($this->post, $name);
} }
return $this->input($this->post, $name, $default, $filter); return $this->input($this->post, $name, $default, $filter);
@ -792,8 +798,8 @@ class Request
$this->request = $_REQUEST; $this->request = $_REQUEST;
} }
if (is_array($name)) { if (is_array($name)) {
$this->param = []; $this->param = [];
$this->mergeParam = false; $this->mergeParam = false;
return $this->request = array_merge($this->request, $name); return $this->request = array_merge($this->request, $name);
} }
return $this->input($this->request, $name, $default, $filter); return $this->input($this->request, $name, $default, $filter);
@ -1294,7 +1300,7 @@ class Request
*/ */
public function ip($type = 0, $adv = true) public function ip($type = 0, $adv = true)
{ {
$type = $type ? 1 : 0; $type = $type ? 1 : 0;
static $ip = null; static $ip = null;
if (null !== $ip) { if (null !== $ip) {
return $ip[$type]; return $ip[$type];
@ -1633,7 +1639,7 @@ class Request
throw new \think\exception\HttpResponseException($response); throw new \think\exception\HttpResponseException($response);
} elseif (Cache::has($key)) { } elseif (Cache::has($key)) {
list($content, $header) = Cache::get($key); list($content, $header) = Cache::get($key);
$response = Response::create($content)->header($header); $response = Response::create($content)->header($header);
throw new \think\exception\HttpResponseException($response); throw new \think\exception\HttpResponseException($response);
} else { } else {
$this->cache = [$key, $expire, $tag]; $this->cache = [$key, $expire, $tag];

View File

@ -880,12 +880,16 @@ class Validate
// 支持多个字段验证 // 支持多个字段验证
$fields = explode('^', $key); $fields = explode('^', $key);
foreach ($fields as $key) { foreach ($fields as $key) {
$map[$key] = $data[$key]; if (isset($data[$key])) {
$map[$key] = $data[$key];
}
} }
} elseif (strpos($key, '=')) { } elseif (strpos($key, '=')) {
parse_str($key, $map); parse_str($key, $map);
} else { } elseif (isset($data[$field])) {
$map[$key] = $data[$field]; $map[$key] = $data[$field];
} else {
$map = [];
} }
$pk = isset($rule[3]) ? $rule[3] : $db->getPk(); $pk = isset($rule[3]) ? $rule[3] : $db->getPk();

View File

@ -54,7 +54,7 @@ class Query
// 回调事件 // 回调事件
private static $event = []; private static $event = [];
// 读取主库 // 读取主库
private static $readMaster = []; protected static $readMaster = [];
/** /**
* 构造函数 * 构造函数

View File

@ -202,7 +202,14 @@ class HasMany extends Relation
*/ */
public function save($data) public function save($data)
{ {
$model = $this->make($data); if ($data instanceof Model) {
$data = $data->getData();
}
// 保存关联表数据
$data[$this->foreignKey] = $this->parent->{$this->localKey};
$model = new $this->model();
return $model->save($data) ? $model : false; return $model->save($data) ? $model : false;
} }

View File

@ -245,9 +245,19 @@ class MorphMany extends Relation
*/ */
public function save($data) public function save($data)
{ {
$model = $this->make($data); if ($data instanceof Model) {
$data = $data->getData();
}
return $model->save($data) ? $model : false; // 保存关联表数据
$pk = $this->parent->getPk();
$data[$this->morphKey] = $this->parent->$pk;
$data[$this->morphType] = $this->type;
$model = new $this->model();
return $model->save() ? $model : false;
} }
/** /**

View File

@ -199,7 +199,18 @@ class MorphOne extends Relation
*/ */
public function save($data) public function save($data)
{ {
$model = $this->make($data); if ($data instanceof Model) {
$data = $data->getData();
}
// 保存关联表数据
$pk = $this->parent->getPk();
$data[$this->morphKey] = $this->parent->$pk;
$data[$this->morphType] = $this->type;
$model = new $this->model();
return $model->save() ? $model : false; return $model->save() ? $model : false;
} }