From ab3be81f4a3d6564d65efc1b9d481f17af00390f Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 28 Feb 2025 16:28:49 +0800 Subject: [PATCH] * [bug#59881,done,0.5h] fix didn't show comment image error. --- module/testtask/control.php | 36 +++++++++++++++++----- module/testtask/model.php | 60 ++++++++++--------------------------- 2 files changed, 44 insertions(+), 52 deletions(-) diff --git a/module/testtask/control.php b/module/testtask/control.php index 6b11343493..c25ae14a0d 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -608,11 +608,16 @@ class testtask extends control { $task = $this->testtaskZen->buildTaskForStart($taskID); - $this->testtask->start($task); + $changes = $this->testtask->start($task); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; + if($changes || $this->post->comment) + { + $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Started', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => true)); } @@ -644,11 +649,16 @@ class testtask extends control { $task = $this->testtaskZen->buildTaskForClose($taskID); - $this->testtask->close($task); + $changes = $this->testtask->close($task); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; + if($changes || $this->post->comment) + { + $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Closed', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => true)); } @@ -680,11 +690,16 @@ class testtask extends control { $task = $this->testtaskZen->buildTaskForBlock($taskID); - $this->testtask->block($task); + $changes = $this->testtask->block($task); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; + if($changes || $this->post->comment) + { + $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Blocked', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => true)); } @@ -716,11 +731,16 @@ class testtask extends control { $task = $this->testtaskZen->buildTaskForActivate($taskID); - $this->testtask->activate($task); + $changes = $this->testtask->activate($task); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; + if($changes || $this->post->comment) + { + $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Activated', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + $message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess; return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => true)); } diff --git a/module/testtask/model.php b/module/testtask/model.php index a1c737c7ca..33ebf466ae 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -679,11 +679,11 @@ class testtaskModel extends model * 开始一个测试单。 * Start testtask. * - * @param object $task + * @param object $task * @access public - * @return bool + * @return bool|array */ - public function start(object $task): bool + public function start(object $task): bool|array { $taskID = (int)$task->id; $oldTask = $this->fetchByID($taskID); @@ -696,25 +696,18 @@ class testtaskModel extends model ->exec(); if(dao::isError()) return false; - $changes = common::createChanges($oldTask, $task); - if($changes || $task->comment) - { - $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Started', $task->comment); - $this->action->logHistory($actionID, $changes); - } - - return !dao::isError(); + return common::createChanges($oldTask, $task); } /** * 关闭一个测试单。 * Close a testtask. * - * @param object $task + * @param object $task * @access public - * @return bool + * @return bool|array */ - public function close(object $task): bool + public function close(object $task): bool|array { $taskID = (int)$task->id; $oldTask = $this->fetchByID($taskID); @@ -731,25 +724,18 @@ class testtaskModel extends model ->exec(); if(dao::isError()) return false; - $changes = common::createChanges($oldTask, $task); - if($changes || $task->comment) - { - $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Closed', $task->comment); - $this->action->logHistory($actionID, $changes); - } - - return !dao::isError(); + return common::createChanges($oldTask, $task); } /** * 阻塞一个测试单。 * Block a testtask. * - * @param object $task + * @param object $task * @access public - * @return bool + * @return bool|array */ - public function block(object $task): bool + public function block(object $task): bool|array { $taskID = (int)$task->id; $oldTask = $this->fetchByID($taskID); @@ -762,25 +748,18 @@ class testtaskModel extends model ->exec(); if(dao::isError()) return false; - $changes = common::createChanges($oldTask, $task); - if($changes || $task->comment) - { - $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Blocked', $task->comment); - $this->action->logHistory($actionID, $changes); - } - - return !dao::isError(); + return common::createChanges($oldTask, $task); } /** * 激活一个测试单。 * Activate a testtask. * - * @param object $task + * @param object $task * @access public - * @return bool + * @return bool|array */ - public function activate(object $task): bool + public function activate(object $task): bool|array { $taskID = (int)$task->id; $oldTask = $this->fetchByID($taskID); @@ -793,14 +772,7 @@ class testtaskModel extends model ->exec(); if(dao::isError()) return false; - $changes = common::createChanges($oldTask, $task); - if($changes || $task->comment) - { - $actionID = $this->loadModel('action')->create('testtask', $taskID, 'Activated', $task->comment); - $this->action->logHistory($actionID, $changes); - } - - return !dao::isError(); + return common::createChanges($oldTask, $task); } /**