diff --git a/composer.lock b/composer.lock index 1937e5ed5..c6780b1c0 100644 --- a/composer.lock +++ b/composer.lock @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "ca6df0b64b3d22c210260a218bb31134661c881d" + "reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ca6df0b64b3d22c210260a218bb31134661c881d", - "reference": "ca6df0b64b3d22c210260a218bb31134661c881d", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1f0c1902fcab3cd7d257f79d607712619a4b660e", + "reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2019-12-16T03:27:06+00:00" + "time": "2019-12-17T10:24:30+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index c1875a43e..e545a0ee6 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "ca6df0b64b3d22c210260a218bb31134661c881d" + "reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ca6df0b64b3d22c210260a218bb31134661c881d", - "reference": "ca6df0b64b3d22c210260a218bb31134661c881d", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1f0c1902fcab3cd7d257f79d607712619a4b660e", + "reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2019-12-16T03:27:06+00:00", + "time": "2019-12-17T10:24:30+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index e1f479a33..8cf3ec2bb 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/command/Install.php b/vendor/zoujingli/think-library/src/command/Install.php index adf3b83d5..4f04e3dfe 100644 --- a/vendor/zoujingli/think-library/src/command/Install.php +++ b/vendor/zoujingli/think-library/src/command/Install.php @@ -52,10 +52,11 @@ class Install extends Command */ protected $bind = [ 'admin' => [ - 'rules' => [ - 'think', - 'app/admin', - ], + 'rules' => ['think', 'app/admin'], + 'ignore' => [], + ], + 'wechat' => [ + 'rules' => ['app/wechat'], 'ignore' => [], ], 'static' => [ diff --git a/vendor/zoujingli/think-library/src/service/InstallService.php b/vendor/zoujingli/think-library/src/service/InstallService.php index bac9c11d3..a4d03e890 100644 --- a/vendor/zoujingli/think-library/src/service/InstallService.php +++ b/vendor/zoujingli/think-library/src/service/InstallService.php @@ -166,10 +166,9 @@ class InstallService extends Service foreach ($local as $t) $_local[$t['name']] = $t; unset($serve, $local); // 线上数据差异计算 - foreach ($_serve as $t) if (isset($_local[$t['name']])) array_push($_new, [ + foreach ($_serve as $t) isset($_local[$t['name']]) ? array_push($_new, [ 'type' => $t['hash'] === $_local[$t['name']]['hash'] ? null : 'mod', 'name' => $t['name'], - ]); - else array_push($_new, ['type' => 'add', 'name' => $t['name']]); + ]) : array_push($_new, ['type' => 'add', 'name' => $t['name']]); // 本地数据增量计算 foreach ($_local as $t) if (!isset($_serve[$t['name']])) array_push($_new, ['type' => 'del', 'name' => $t['name']]); unset($_serve, $_local); diff --git a/vendor/zoujingli/think-library/src/service/JsonRpcClientService.php b/vendor/zoujingli/think-library/src/service/JsonRpcClientService.php index bcfc0af70..ef6d925da 100644 --- a/vendor/zoujingli/think-library/src/service/JsonRpcClientService.php +++ b/vendor/zoujingli/think-library/src/service/JsonRpcClientService.php @@ -44,35 +44,28 @@ class JsonRpcClientService extends Service */ public function create($proxy) { - $this->proxy = $proxy; $this->requestid = CodeExtend::uniqidNumber(); + $this->proxy = $proxy; return $this; } /** - * 执行 JsonRCP 请求 + * 执行 JsonRpc 请求 * @param string $method * @param array $params - * @return array|boolean + * @return mixed * @throws \think\Exception */ public function __call($method, $params) { - // check - if (!is_scalar($method)) { - throw new \think\Exception('Method name has no scalar value'); - } - // check - if (is_array($params)) { - $params = array_values($params); - } else { - throw new \think\Exception('Params must be given as array'); - } - // performs the HTTP POST + // Performs the HTTP POST $options = [ 'http' => [ - 'method' => 'POST', 'header' => 'Content-type: application/json', - 'content' => json_encode(['method' => $method, 'params' => $params, 'id' => $this->requestid], JSON_UNESCAPED_UNICODE), + 'method' => 'POST', + 'header' => 'Content-type: application/json', + 'content' => json_encode([ + 'jsonrpc' => '2.0', 'method' => $method, 'params' => $params, 'id' => $this->requestid, + ], JSON_UNESCAPED_UNICODE), ], ]; if ($fp = fopen($this->proxy, 'r', false, stream_context_create($options))) { @@ -81,16 +74,16 @@ class JsonRpcClientService extends Service fclose($fp); $response = json_decode($response, true); } else { - throw new \think\Exception("Unable to connect to {$this->proxy}"); + throw new \think\Exception("无法连接到 {$this->proxy}"); } - // final checks and return + // Final checks and return if ($response['id'] != $this->requestid) { - throw new \think\Exception("Incorrect response id (request id: {$this->requestid}, response id: {$response['id']})"); + throw new \think\Exception("错误的响应标记 (请求标记: {$this->requestid}, 响应标记: {$response['id']})"); } if (is_null($response['error'])) { return $response['result']; } else { - throw new \think\Exception("Request error: {$response['error']}"); + throw new \think\Exception("请求错误:[{$response['error']['code']}] {$response['error']['message']}"); } } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/service/JsonRpcServerService.php b/vendor/zoujingli/think-library/src/service/JsonRpcServerService.php index 9441783fd..827c052cc 100644 --- a/vendor/zoujingli/think-library/src/service/JsonRpcServerService.php +++ b/vendor/zoujingli/think-library/src/service/JsonRpcServerService.php @@ -28,7 +28,6 @@ class JsonRpcServerService extends Service /** * 设置监听对象 * @param mixed $object - * @throws \think\Exception */ public function handle($object) { @@ -41,18 +40,23 @@ class JsonRpcServerService extends Service } else { // Reads the input data $request = json_decode(file_get_contents('php://input'), true); - if (empty($request['id'])) { - throw new \think\Exception('JsonRpc Request id cannot be empty'); - } - // Executes the task on local object - try { + if (empty($request)) { + $error = ['code' => '-32700', 'message' => '语法解析错误', 'meaning' => '服务端接收到无效的JSON']; + $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; + } elseif (!isset($request['id']) || !isset($request['method']) || !isset($request['params'])) { + $error = ['code' => '-32600', 'message' => '无效的请求', 'meaning' => '发送的JSON不是一个有效的请求对象']; + $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; + } else try { + // Executes the task on local object if ($result = @call_user_func_array([$object, $request['method']], $request['params'])) { - $response = ['id' => $request['id'], 'result' => $result, 'error' => null]; + $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => $result, 'error' => null]; } else { - $response = ['id' => $request['id'], 'result' => null, 'error' => 'unknown method or incorrect parameters']; + $error = ['code' => '-32601', 'message' => '找不到方法', 'meaning' => '该方法不存在或无效']; + $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; } } catch (\Exception $e) { - $response = ['id' => $request['id'], 'result' => null, 'error' => $e->getMessage()]; + $error = ['code' => $e->getCode(), 'message' => $e->getMessage()]; + $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error]; } // Output the response throw new HttpResponseException(json($response)->contentType('text/javascript'));