From 584eba4b62c80a21b7b5866078bf8db3182f1dba Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 13 Jan 2020 14:49:12 +0800 Subject: [PATCH] =?UTF-8?q?ComposerUpdate=20&=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91OSS=E4=B8=8B=E8=BD=BD=E5=8E=9F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/api/upload.js | 1 + composer.lock | 28 ++++++++-------- vendor/composer/installed.json | 32 +++++++++---------- vendor/services.php | 2 +- vendor/topthink/framework/src/think/App.php | 2 +- .../framework/src/think/Middleware.php | 16 ++++------ .../topthink/framework/src/think/Request.php | 26 +++++++++------ .../topthink/framework/src/think/Validate.php | 2 +- .../think/console/command/optimize/Schema.php | 4 +-- .../framework/src/think/route/Rule.php | 10 +++--- .../src/think/route/dispatch/Controller.php | 15 ++++++--- .../framework/src/think/session/Store.php | 2 +- vendor/topthink/framework/tests/CacheTest.php | 4 +-- .../topthink/think-orm/src/db/BaseQuery.php | 12 +++++++ vendor/topthink/think-orm/src/db/Query.php | 12 ------- .../think-orm/src/model/concern/Attribute.php | 2 +- .../src/storage/AliossStorage.php | 6 +++- 17 files changed, 95 insertions(+), 81 deletions(-) diff --git a/app/admin/view/api/upload.js b/app/admin/view/api/upload.js index 30427a57e..a966e30d3 100644 --- a/app/admin/view/api/upload.js +++ b/app/admin/view/api/upload.js @@ -41,6 +41,7 @@ define(['md5'], function (SparkMD5, allowExtsMimes) { uploader.config.data.signature = ret.data.signature; uploader.config.data.OSSAccessKeyId = ret.data.OSSAccessKeyId; uploader.config.data.success_action_status = 200; + uploader.config.data['Content-Disposition'] = 'attachment;filename=' + encodeURIComponent(file.name); } object.upload(index, file); } else if (parseInt(ret.code) === 200) { diff --git a/composer.lock b/composer.lock index 7d6ced173..6c0cc6945 100644 --- a/composer.lock +++ b/composer.lock @@ -558,16 +558,16 @@ }, { "name": "topthink/framework", - "version": "v6.0.1", + "version": "v6.0.2", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "501f3dd17dc6266e17b7d8df3e9fd090bd2cc85f" + "reference": "1444cce94b40a836958380b160a5fb7bfc165daf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/501f3dd17dc6266e17b7d8df3e9fd090bd2cc85f", - "reference": "501f3dd17dc6266e17b7d8df3e9fd090bd2cc85f", + "url": "https://api.github.com/repos/top-think/framework/zipball/1444cce94b40a836958380b160a5fb7bfc165daf", + "reference": "1444cce94b40a836958380b160a5fb7bfc165daf", "shasum": "", "mirrors": [ { @@ -622,7 +622,7 @@ "orm", "thinkphp" ], - "time": "2019-12-24T07:57:03+00:00" + "time": "2020-01-13T05:48:05+00:00" }, { "name": "topthink/think-helper", @@ -721,16 +721,16 @@ }, { "name": "topthink/think-orm", - "version": "v2.0.30", + "version": "v2.0.31", "source": { "type": "git", "url": "https://github.com/top-think/think-orm.git", - "reference": "b6f61fc243974a25cb6914b84a529b373a717626" + "reference": "d6965dfae21f150e29cc899ab6f9b1bd2c0f2ee4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-orm/zipball/b6f61fc243974a25cb6914b84a529b373a717626", - "reference": "b6f61fc243974a25cb6914b84a529b373a717626", + "url": "https://api.github.com/repos/top-think/think-orm/zipball/d6965dfae21f150e29cc899ab6f9b1bd2c0f2ee4", + "reference": "d6965dfae21f150e29cc899ab6f9b1bd2c0f2ee4", "shasum": "", "mirrors": [ { @@ -768,7 +768,7 @@ "database", "orm" ], - "time": "2020-01-02T09:09:50+00:00" + "time": "2020-01-07T10:05:10+00:00" }, { "name": "topthink/think-template", @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "88d74e6f666cc23103da97e8e2307ecc5db1b031" + "reference": "73ce73f61a90994e23b7616c73655440f50790a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/88d74e6f666cc23103da97e8e2307ecc5db1b031", - "reference": "88d74e6f666cc23103da97e8e2307ecc5db1b031", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/73ce73f61a90994e23b7616c73655440f50790a0", + "reference": "73ce73f61a90994e23b7616c73655440f50790a0", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-01-11T07:50:11+00:00" + "time": "2020-01-13T06:39:14+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 640d5cfc5..7b64bfe9f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -569,17 +569,17 @@ }, { "name": "topthink/framework", - "version": "v6.0.1", - "version_normalized": "6.0.1.0", + "version": "v6.0.2", + "version_normalized": "6.0.2.0", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "501f3dd17dc6266e17b7d8df3e9fd090bd2cc85f" + "reference": "1444cce94b40a836958380b160a5fb7bfc165daf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/501f3dd17dc6266e17b7d8df3e9fd090bd2cc85f", - "reference": "501f3dd17dc6266e17b7d8df3e9fd090bd2cc85f", + "url": "https://api.github.com/repos/top-think/framework/zipball/1444cce94b40a836958380b160a5fb7bfc165daf", + "reference": "1444cce94b40a836958380b160a5fb7bfc165daf", "shasum": "", "mirrors": [ { @@ -606,7 +606,7 @@ "mockery/mockery": "^1.2", "phpunit/phpunit": "^7.0" }, - "time": "2019-12-24T07:57:03+00:00", + "time": "2020-01-13T05:48:05+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -738,17 +738,17 @@ }, { "name": "topthink/think-orm", - "version": "v2.0.30", - "version_normalized": "2.0.30.0", + "version": "v2.0.31", + "version_normalized": "2.0.31.0", "source": { "type": "git", "url": "https://github.com/top-think/think-orm.git", - "reference": "b6f61fc243974a25cb6914b84a529b373a717626" + "reference": "d6965dfae21f150e29cc899ab6f9b1bd2c0f2ee4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-orm/zipball/b6f61fc243974a25cb6914b84a529b373a717626", - "reference": "b6f61fc243974a25cb6914b84a529b373a717626", + "url": "https://api.github.com/repos/top-think/think-orm/zipball/d6965dfae21f150e29cc899ab6f9b1bd2c0f2ee4", + "reference": "d6965dfae21f150e29cc899ab6f9b1bd2c0f2ee4", "shasum": "", "mirrors": [ { @@ -764,7 +764,7 @@ "psr/simple-cache": "^1.0", "topthink/think-helper": "^3.1" }, - "time": "2020-01-02T09:09:50+00:00", + "time": "2020-01-07T10:05:10+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "88d74e6f666cc23103da97e8e2307ecc5db1b031" + "reference": "73ce73f61a90994e23b7616c73655440f50790a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/88d74e6f666cc23103da97e8e2307ecc5db1b031", - "reference": "88d74e6f666cc23103da97e8e2307ecc5db1b031", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/73ce73f61a90994e23b7616c73655440f50790a0", + "reference": "73ce73f61a90994e23b7616c73655440f50790a0", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-01-11T07:50:11+00:00", + "time": "2020-01-13T06:39:14+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index f9b213877..5474e87f5 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/topthink/framework/src/think/App.php b/vendor/topthink/framework/src/think/App.php index 7bc271c3c..24c03f39b 100644 --- a/vendor/topthink/framework/src/think/App.php +++ b/vendor/topthink/framework/src/think/App.php @@ -39,7 +39,7 @@ use think\initializer\RegisterService; */ class App extends Container { - const VERSION = '6.0.1'; + const VERSION = '6.0.2'; /** * 应用调试模式 diff --git a/vendor/topthink/framework/src/think/Middleware.php b/vendor/topthink/framework/src/think/Middleware.php index 0a277a1a1..0868fb2ec 100644 --- a/vendor/topthink/framework/src/think/Middleware.php +++ b/vendor/topthink/framework/src/think/Middleware.php @@ -66,7 +66,7 @@ class Middleware { $middleware = $this->buildMiddleware($middleware, $type); - if ($middleware) { + if (!empty($middleware)) { $this->queue[$type][] = $middleware; $this->queue[$type] = array_unique($this->queue[$type], SORT_REGULAR); } @@ -135,11 +135,11 @@ class Middleware return (new Pipeline()) ->through(array_map(function ($middleware) { return function ($request, $next) use ($middleware) { - [$call, $param] = $middleware; + [$call, $params] = $middleware; if (is_array($call) && is_string($call[0])) { $call = [$this->app->make($call[0]), $call[1]]; } - $response = call_user_func($call, $request, $next, $param); + $response = call_user_func($call, $request, $next, ...$params); if (!$response instanceof Response) { throw new LogicException('The middleware must return Response instance'); @@ -182,9 +182,7 @@ class Middleware $handler->report($e); - $response = $handler->render($passable, $e); - - return $response; + return $handler->render($passable, $e); } /** @@ -197,11 +195,11 @@ class Middleware protected function buildMiddleware($middleware, string $type): array { if (is_array($middleware)) { - [$middleware, $param] = $middleware; + [$middleware, $params] = $middleware; } if ($middleware instanceof Closure) { - return [$middleware, $param ?? null]; + return [$middleware, $params ?? []]; } if (!is_string($middleware)) { @@ -220,7 +218,7 @@ class Middleware return []; } - return [[$middleware, 'handle'], $param ?? null]; + return [[$middleware, 'handle'], $params ?? []]; } /** diff --git a/vendor/topthink/framework/src/think/Request.php b/vendor/topthink/framework/src/think/Request.php index 5f8a48179..0053c0b0a 100644 --- a/vendor/topthink/framework/src/think/Request.php +++ b/vendor/topthink/framework/src/think/Request.php @@ -327,12 +327,14 @@ class Request } $request->header = array_change_key_case($header); + $request->server = $_SERVER; + $request->env = $app->env; + + $inputData = $request->getInputData($request->input); - $request->server = $_SERVER; - $request->env = $app->env; $request->get = $_GET; - $request->post = $_POST ?: $request->getInputData($request->input); - $request->put = $request->getInputData($request->input); + $request->post = $_POST ?: $inputData; + $request->put = $inputData; $request->request = $_REQUEST; $request->cookie = $_COOKIE; $request->file = $_FILES ?? []; @@ -982,11 +984,12 @@ class Request protected function getInputData($content): array { - if (false !== strpos($this->contentType(), 'json')) { - return (array) json_decode($content, true); - } elseif (strpos($content, '=')) { + $contentType = $this->contentType(); + if ($contentType == 'application/x-www-form-urlencoded') { parse_str($content, $data); return $data; + } elseif (false !== strpos($contentType, 'json')) { + return (array) json_decode($content, true); } return []; @@ -2051,15 +2054,18 @@ class Request /** * 设置php://input数据 * @access public - * @param string $input RAW数据 + * @param string $input RAW数据 * @return $this */ public function withInput(string $input) { $this->input = $input; if (!empty($input)) { - $this->post = $this->getInputData($input); - $this->put = $this->getInputData($input); + $inputData = $this->getInputData($input); + if (!empty($inputData)) { + $this->post = $inputData; + $this->put = $inputData; + } } return $this; } diff --git a/vendor/topthink/framework/src/think/Validate.php b/vendor/topthink/framework/src/think/Validate.php index a81c4d335..1b6adbde8 100644 --- a/vendor/topthink/framework/src/think/Validate.php +++ b/vendor/topthink/framework/src/think/Validate.php @@ -131,7 +131,7 @@ class Validate 'chsAlphaNum' => '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9]+$/u', 'chsDash' => '/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-]+$/u', 'mobile' => '/^1[3-9]\d{9}$/', - 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/', + 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', 'zip' => '/\d{6}/', ]; diff --git a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php index 77b06e433..29f0bdb64 100644 --- a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php +++ b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php @@ -85,8 +85,8 @@ class Schema extends Command $model = new $class; $table = $model->getTable(); - $dbName = $model->getConnection()->getConfig('database'); - $path = $model->getConnection()->getConfig('schema_cache_path'); + $dbName = $model->db()->getConnection()->getConfig('database'); + $path = $model->db()->getConnection()->getConfig('schema_cache_path'); if (!is_dir($path)) { mkdir($path, 0755, true); } diff --git a/vendor/topthink/framework/src/think/route/Rule.php b/vendor/topthink/framework/src/think/route/Rule.php index fd9e2809e..b0ef3f592 100644 --- a/vendor/topthink/framework/src/think/route/Rule.php +++ b/vendor/topthink/framework/src/think/route/Rule.php @@ -387,17 +387,17 @@ abstract class Rule /** * 指定路由中间件 * @access public - * @param string|array|Closure $middleware 中间件 - * @param mixed $param 参数 + * @param string|array|Closure $middleware 中间件 + * @param mixed $params 参数 * @return $this */ - public function middleware($middleware, $param = null) + public function middleware($middleware, ...$params) { - if (is_null($param) && is_array($middleware)) { + if (empty($params) && is_array($middleware)) { $this->option['middleware'] = $middleware; } else { foreach ((array) $middleware as $item) { - $this->option['middleware'][] = [$item, $param]; + $this->option['middleware'][] = [$item, $params]; } } diff --git a/vendor/topthink/framework/src/think/route/dispatch/Controller.php b/vendor/topthink/framework/src/think/route/dispatch/Controller.php index 413c1a1bc..88094c6e0 100644 --- a/vendor/topthink/framework/src/think/route/dispatch/Controller.php +++ b/vendor/topthink/framework/src/think/route/dispatch/Controller.php @@ -83,7 +83,8 @@ class Controller extends Dispatch ->send($this->request) ->then(function () use ($instance) { // 获取当前操作名 - $action = $this->actionName . $this->rule->config('action_suffix'); + $suffix = $this->rule->config('action_suffix'); + $action = $this->actionName . $suffix; if (is_callable([$instance, $action])) { $vars = $this->request->param(); @@ -91,6 +92,10 @@ class Controller extends Dispatch $reflect = new ReflectionMethod($instance, $action); // 严格获取当前操作方法名 $actionName = $reflect->getName(); + if ($suffix) { + $actionName = substr($actionName, 0, -strlen($suffix)); + } + $this->request->setAction($actionName); } catch (ReflectionException $e) { $reflect = new ReflectionMethod($instance, '__call'); @@ -127,12 +132,12 @@ class Controller extends Dispatch foreach ($middlewares as $key => $val) { if (!is_int($key)) { if (isset($val['only']) && !in_array($this->request->action(true), array_map(function ($item) { - return strtolower($item); - }, is_string($val['only']) ? explode(",", $val['only']) : $val['only']))) { + return strtolower($item); + }, is_string($val['only']) ? explode(",", $val['only']) : $val['only']))) { continue; } elseif (isset($val['except']) && in_array($this->request->action(true), array_map(function ($item) { - return strtolower($item); - }, is_string($val['except']) ? explode(',', $val['except']) : $val['except']))) { + return strtolower($item); + }, is_string($val['except']) ? explode(',', $val['except']) : $val['except']))) { continue; } else { $val = $key; diff --git a/vendor/topthink/framework/src/think/session/Store.php b/vendor/topthink/framework/src/think/session/Store.php index 30f463009..03ece29e3 100644 --- a/vendor/topthink/framework/src/think/session/Store.php +++ b/vendor/topthink/framework/src/think/session/Store.php @@ -118,7 +118,7 @@ class Store */ public function setId($id = null): void { - $this->id = is_string($id) && strlen($id) === 32 ? $id : md5(microtime(true) . session_create_id()); + $this->id = is_string($id) && strlen($id) === 32 && ctype_alnum($id) ? $id : md5(microtime(true) . session_create_id()); } /** diff --git a/vendor/topthink/framework/tests/CacheTest.php b/vendor/topthink/framework/tests/CacheTest.php index 58947d36c..5b5a13cbc 100644 --- a/vendor/topthink/framework/tests/CacheTest.php +++ b/vendor/topthink/framework/tests/CacheTest.php @@ -119,8 +119,8 @@ class CacheTest extends TestCase $redis->shouldReceive("set")->once()->with('foo', 5)->andReturnTrue(); $redis->shouldReceive("incrby")->once()->with('foo', 1)->andReturnTrue(); $redis->shouldReceive("decrby")->once()->with('foo', 2)->andReturnTrue(); - $redis->shouldReceive("get")->once()->with('foo')->andReturn(6); - $redis->shouldReceive("get")->once()->with('foo')->andReturn(4); + $redis->shouldReceive("get")->once()->with('foo')->andReturn('6'); + $redis->shouldReceive("get")->once()->with('foo')->andReturn('4'); $redis->shouldReceive("set")->once()->with('bar', serialize(true))->andReturnTrue(); $redis->shouldReceive("set")->once()->with('baz', serialize(null))->andReturnTrue(); $redis->shouldReceive("del")->once()->with('baz')->andReturnTrue(); diff --git a/vendor/topthink/think-orm/src/db/BaseQuery.php b/vendor/topthink/think-orm/src/db/BaseQuery.php index 1f97e63e2..65b2d2d36 100644 --- a/vendor/topthink/think-orm/src/db/BaseQuery.php +++ b/vendor/topthink/think-orm/src/db/BaseQuery.php @@ -829,6 +829,18 @@ abstract class BaseQuery return $this; } + /** + * 设置自增序列名 + * @access public + * @param string $sequence 自增序列名 + * @return $this + */ + public function sequence(string $sequence = null) + { + $this->options['sequence'] = $sequence; + return $this; + } + /** * 设置JSON字段信息 * @access public diff --git a/vendor/topthink/think-orm/src/db/Query.php b/vendor/topthink/think-orm/src/db/Query.php index 4fc9a99d9..09ee8203f 100644 --- a/vendor/topthink/think-orm/src/db/Query.php +++ b/vendor/topthink/think-orm/src/db/Query.php @@ -228,18 +228,6 @@ class Query extends BaseQuery return $this; } - /** - * 设置自增序列名 - * @access public - * @param string $sequence 自增序列名 - * @return $this - */ - public function sequence(string $sequence = null) - { - $this->options['sequence'] = $sequence; - return $this; - } - /** * 指定强制索引 * @access public diff --git a/vendor/topthink/think-orm/src/model/concern/Attribute.php b/vendor/topthink/think-orm/src/model/concern/Attribute.php index a02dc3fb7..9e4367b8f 100644 --- a/vendor/topthink/think-orm/src/model/concern/Attribute.php +++ b/vendor/topthink/think-orm/src/model/concern/Attribute.php @@ -424,7 +424,7 @@ trait Attribute break; case 'datetime': $value = is_numeric($value) ? $value : strtotime($value); - $value = $this->formatDateTime('Y-m-d H:i:s.u', $value); + $value = $this->formatDateTime('Y-m-d H:i:s.u', $value, true); break; case 'object': if (is_object($value)) { diff --git a/vendor/zoujingli/think-library/src/storage/AliossStorage.php b/vendor/zoujingli/think-library/src/storage/AliossStorage.php index c7394c923..89d85da97 100644 --- a/vendor/zoujingli/think-library/src/storage/AliossStorage.php +++ b/vendor/zoujingli/think-library/src/storage/AliossStorage.php @@ -99,9 +99,10 @@ class AliossStorage extends Storage * @param string $name 文件名称 * @param string $file 文件内容 * @param boolean $safe 安全模式 + * @param string $attachment 下载名称 * @return array */ - public function set($name, $file, $safe = false) + public function set($name, $file, $safe = false, $attachment = null) { $token = $this->buildUploadToken($name); $data = ['key' => $name]; @@ -109,6 +110,9 @@ class AliossStorage extends Storage $data['Signature'] = $token['signature']; $data['OSSAccessKeyId'] = $this->accessKey; $data['success_action_status'] = '200'; + if (is_string($attachment) && strlen($attachment) > 0) { + $data['Content-Disposition'] = "attachment;filename=" . urlencode($attachment); + } $file = ['field' => 'file', 'name' => $name, 'content' => $file]; if (is_numeric(stripos(HttpExtend::submit($this->upload(), $data, $file), '200 OK'))) { return ['file' => $this->path($name, $safe), 'url' => $this->url($name, $safe), 'key' => $name];