浏览代码

ComposerUpdate

Anyon 4 年之前
父节点
当前提交
c59ca0b3ca

+ 1 - 1
.gitignore

@@ -5,5 +5,5 @@
 /runtime
 /safefile
 /nbproject
-/public/upload
 /composer.lock
+/public/upload

+ 4 - 4
composer.lock

@@ -929,12 +929,12 @@
             "source": {
                 "type": "git",
                 "url": "https://github.com/zoujingli/ThinkLibrary.git",
-                "reference": "8626798197fcdef636619e59b7151ca9f2952f63"
+                "reference": "2fe569700bd8d7e2a24054f3592c5b06171c617c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/8626798197fcdef636619e59b7151ca9f2952f63",
-                "reference": "8626798197fcdef636619e59b7151ca9f2952f63",
+                "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2fe569700bd8d7e2a24054f3592c5b06171c617c",
+                "reference": "2fe569700bd8d7e2a24054f3592c5b06171c617c",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -978,7 +978,7 @@
             ],
             "description": "ThinkPHP v6.0 Development Library",
             "homepage": "http://framework.thinkadmin.top",
-            "time": "2020-06-20T09:56:03+00:00"
+            "time": "2020-06-22T09:29:56+00:00"
         },
         {
             "name": "zoujingli/wechat-developer",

+ 4 - 4
vendor/composer/installed.json

@@ -955,12 +955,12 @@
         "source": {
             "type": "git",
             "url": "https://github.com/zoujingli/ThinkLibrary.git",
-            "reference": "8626798197fcdef636619e59b7151ca9f2952f63"
+            "reference": "2fe569700bd8d7e2a24054f3592c5b06171c617c"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/8626798197fcdef636619e59b7151ca9f2952f63",
-            "reference": "8626798197fcdef636619e59b7151ca9f2952f63",
+            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2fe569700bd8d7e2a24054f3592c5b06171c617c",
+            "reference": "2fe569700bd8d7e2a24054f3592c5b06171c617c",
             "shasum": "",
             "mirrors": [
                 {
@@ -976,7 +976,7 @@
             "ext-json": "*",
             "topthink/framework": "^6.0"
         },
-        "time": "2020-06-20T09:56:03+00:00",
+        "time": "2020-06-22T09:29:56+00:00",
         "type": "library",
         "extra": {
             "think": {

+ 1 - 1
vendor/services.php

@@ -1,5 +1,5 @@
 <?php 
-// This file is automatically generated at:2020-06-20 18:06:40
+// This file is automatically generated at:2020-06-22 17:43:32
 declare (strict_types = 1);
 return array (
   0 => 'think\\app\\Service',

+ 19 - 17
vendor/zoujingli/think-library/src/Command.php

@@ -45,33 +45,35 @@ class Command extends ThinkCommand
      * @param Input $input
      * @param Output $output
      * @return $this
+     * @throws Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     protected function initialize(Input $input, Output $output)
     {
         $this->queue = QueueService::instance();
         $this->process = ProcessService::instance();
+        if (defined('WorkQueueCode')) {
+            if (!$this->queue instanceof QueueService) {
+                $this->queue = QueueService::instance();
+            }
+            if ($this->queue->code !== WorkQueueCode) {
+                $this->queue->initialize(WorkQueueCode);
+            }
+        }
         return $this;
     }
 
     /**
-     * 设置当前任务进度
+     * 设置进度消息并继续执行
      * @param null|string $message 进度消息
      * @param null|integer $progress 进度数值
      * @return Command
-     * @throws Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
      */
     protected function setQueueProgress($message = null, $progress = null)
     {
         if (defined('WorkQueueCode')) {
-            if (!$this->queue instanceof QueueService) {
-                $this->queue = QueueService::instance();
-            }
-            if ($this->queue->code !== WorkQueueCode) {
-                $this->queue->initialize(WorkQueueCode);
-            }
             $this->queue->progress(2, $message, $progress);
         } elseif (is_string($message)) {
             $this->output->writeln($message);
@@ -80,15 +82,15 @@ class Command extends ThinkCommand
     }
 
     /**
-     * 设置成功的消息
+     * 设置失败消息并结束进程
      * @param string $message 消息内容
      * @return Command
      * @throws Exception
      */
-    protected function setQueueSuccess($message)
+    protected function setQueueError($message)
     {
         if (defined('WorkQueueCode')) {
-            throw new Exception($message, 3, WorkQueueCode);
+            throw new Exception($message, 4, WorkQueueCode);
         } elseif (is_string($message)) {
             $this->output->writeln($message);
         }
@@ -96,15 +98,15 @@ class Command extends ThinkCommand
     }
 
     /**
-     * 设置失败的消息
+     * 设置成功消息并结束进程
      * @param string $message 消息内容
      * @return Command
      * @throws Exception
      */
-    protected function setQueueError($message)
+    protected function setQueueSuccess($message)
     {
         if (defined('WorkQueueCode')) {
-            throw new Exception($message, 4, WorkQueueCode);
+            throw new Exception($message, 3, WorkQueueCode);
         } elseif (is_string($message)) {
             $this->output->writeln($message);
         }

+ 1 - 1
vendor/zoujingli/think-library/src/Library.php

@@ -87,7 +87,7 @@ class Library extends Service
             }, 'route');
         }
         // 动态加入应用函数
-        $sysRule = "{$this->app->getAppPath()}*/sys.php";
+        $sysRule = "{$this->app->getBasePath()}*/sys.php";
         foreach (glob($sysRule) as $file) includeFile($file);
     }
 }

+ 10 - 8
vendor/zoujingli/think-library/src/command/Queue.php

@@ -98,11 +98,11 @@ class Queue extends Command
             if ($this->process->iswin()) {
                 $this->process->exec("start http://{$host}:{$port}");
             }
-            $this->output->writeln("WebServer process already exist for pid {$result['0']['pid']}");
+            $this->output->writeln("WebServer process already exist for pid {$result[0]['pid']}");
         } else {
             [$this->process->create($command), usleep(2000)];
             if (count($result = $this->process->query($command)) > 0) {
-                $this->output->writeln("WebServer process started successfully for pid {$result['0']['pid']}");
+                $this->output->writeln("WebServer process started successfully for pid {$result[0]['pid']}");
                 if ($this->process->iswin()) {
                     $this->process->exec("start http://{$host}:{$port}");
                 }
@@ -192,7 +192,7 @@ class Queue extends Command
         $this->app->db->name($this->table)->whereOr([$map1, $map2])->chunk(100, function (Collection $result) use ($total, &$loops, &$timeout) {
             foreach ($result->toArray() as $item) {
                 $item['loops_time'] > 0 ? $loops++ : $timeout++;
-                $prefix = str_pad($timeout + $loops, strlen("{$total}"), '0', STR_PAD_LEFT);
+                $prefix = str_pad($timeout + $loops, strlen("{$total}"), 0, STR_PAD_LEFT);
                 if ($item['loops_time'] > 0) {
                     $this->setQueueProgress("[{$prefix}/{$total}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total);
                     [$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!'];
@@ -233,7 +233,7 @@ class Queue extends Command
         $this->output->writeln("\tYou can exit with <info>`CTRL-C`</info>");
         $this->output->writeln('============== LISTENING ==============');
         while (true) {
-            $where = [['status', '=', '1'], ['exec_time', '<=', time()]];
+            list($last, $where) = [microtime(true), [['status', '=', 1], ['exec_time', '<=', time()]]];
             $this->app->db->name($this->table)->where($where)->order('exec_time asc')->chunk(100, function (Collection $result) {
                 foreach ($result->toArray() as $vo) try {
                     $command = $this->process->think("xadmin:queue dorun {$vo['code']} -");
@@ -245,12 +245,14 @@ class Queue extends Command
                     }
                 } catch (\Exception $exception) {
                     $this->app->db->name($this->table)->where(['code' => $vo['code']])->update([
-                        'status' => '4', 'outer_time' => time(), 'exec_desc' => $exception->getMessage(),
+                        'status' => 4, 'outer_time' => time(), 'exec_desc' => $exception->getMessage(),
                     ]);
                     $this->output->error("Execution failed -> [{$vo['code']}] {$vo['title']},{$exception->getMessage()}");
                 }
             });
-            usleep(500000);
+            if (microtime(true) - $last < 0.5000) {
+                usleep(500000);
+            }
         }
     }
 
@@ -268,12 +270,12 @@ class Queue extends Command
             $this->queue->initialize($this->code);
             if (empty($this->queue->record) || intval($this->queue->record['status']) !== 1) {
                 // 这里不做任何处理(该任务可能在其它地方已经在执行)
-                $this->output->warning($message = "The or status of task {$this->code} is abnormal");
+                $this->output->warning("The or status of task {$this->code} is abnormal");
             } else {
                 // 锁定任务状态,防止任务再次被执行
                 $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([
                     'enter_time' => microtime(true), 'attempts' => $this->app->db->raw('attempts+1'),
-                    'outer_time' => '0', 'exec_pid' => getmypid(), 'exec_desc' => '', 'status' => '2',
+                    'outer_time' => 0, 'exec_pid' => getmypid(), 'exec_desc' => '', 'status' => 2,
                 ]);
                 $this->queue->progress(2, '>>> 任务处理开始 <<<', 0);
                 // 设置进程标题

+ 6 - 9
vendor/zoujingli/think-library/src/helper/DeleteHelper.php

@@ -29,7 +29,7 @@ class DeleteHelper extends Helper
      * 表单额外更新条件
      * @var array
      */
-    protected $map;
+    protected $where;
 
     /**
      * 数据对象主键名称
@@ -53,16 +53,16 @@ class DeleteHelper extends Helper
      */
     public function init($dbQuery, $field = '', $where = [])
     {
-        $this->map = $where;
+        $this->where = $where;
         $this->query = $this->buildQuery($dbQuery);
         $this->field = $field ?: $this->query->getPk();
         $this->value = $this->app->request->post($this->field, null);
         // 主键限制处理
-        if (!isset($this->map[$this->field]) && is_string($this->value)) {
+        if (!isset($this->where[$this->field]) && is_string($this->value)) {
             $this->query->whereIn($this->field, explode(',', $this->value));
         }
         // 前置回调处理
-        if (false === $this->controller->callback('_delete_filter', $this->query, $this->map)) {
+        if (false === $this->controller->callback('_delete_filter', $this->query, $this->where)) {
             return null;
         }
         // 执行删除操作
@@ -72,11 +72,8 @@ class DeleteHelper extends Helper
             if (in_array('deleted', $fields)) $data['deleted'] = 1;
             if (in_array('is_deleted', $fields)) $data['is_deleted'] = 1;
         }
-        if (empty($data)) {
-            $result = $this->query->where($this->map)->update($data);
-        } else {
-            $result = $this->query->where($this->map)->delete();
-        }
+        empty($this->where) or $this->query->where($this->where);
+        $result = empty($data) ? $this->query->delete() : $this->query->update($data);
         // 结果回调处理
         if (false === $this->controller->callback('_delete_result', $result)) {
             return $result;

+ 11 - 6
vendor/zoujingli/think-library/src/service/ModuleService.php

@@ -32,7 +32,7 @@ class ModuleService extends Service
      * @param ZipArchive $file 安装包
      * @return array
      */
-    public function install($name, ZipArchive $file)
+    public function install(string $name, ZipArchive $file): array
     {
         // 安装包检查
         list($state, $message) = $this->checkInstall($name, $file);
@@ -47,12 +47,17 @@ class ModuleService extends Service
 
     /**
      * 移除应用模块
-     * @param string $name
+     * @param string $name 模块名称
+     * @return array
      */
-    public function remove($name)
+    public function remove(string $name): array
     {
         $directory = $this->app->getBasePath() . $name;
-        $this->forceRemove($directory);
+        if (file_exists($directory) && is_dir($directory)) {
+            return [0, '提交移除应用模块指令成功'];
+        } else {
+            return [1, '待删除的应用模块不存在'];
+        }
     }
 
     /**
@@ -61,7 +66,7 @@ class ModuleService extends Service
      * @param ZipArchive $file 安装包
      * @return array
      */
-    private function checkInstall($name, ZipArchive $file)
+    private function checkInstall(string $name, ZipArchive $file): array
     {
         $directory = "{$file->filename}.files";
         file_exists($directory) || mkdir($directory, 0755, true);
@@ -82,7 +87,7 @@ class ModuleService extends Service
      * 强制删除指定的目录
      * @param string $directory
      */
-    private function forceRemove($directory)
+    private function forceRemove(string $directory)
     {
         if (file_exists($directory) && is_dir($directory) && $handle = opendir($directory)) {
             while (false !== ($item = readdir($handle))) if (!in_array($item, ['.', '..'])) {

+ 1 - 1
vendor/zoujingli/think-library/src/service/OpenService.php

@@ -62,7 +62,7 @@ class OpenService extends Service
      * @return array
      * @throws \think\admin\Exception
      */
-    public function doRequest(string $uri, array $data = [])
+    public function doRequest(string $uri, array $data = []): array
     {
         [$time, $nostr, $json] = [time(), uniqid(), json_encode($data)];
         $sign = md5($this->appid . '#' . $json . '#' . $time . '#' . $this->appkey . '#' . $nostr);