From 21eff4ddb5afa88189a360056f11f8d5ffd7e580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E9=87=91=E5=8B=87?= Date: Mon, 22 Dec 2025 15:00:03 +0800 Subject: [PATCH] * [apiv2] Check testcase exists. --- module/testcase/control.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index 3d7562a8c5..588e08b8a7 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -599,7 +599,7 @@ class testcase extends control public function edit(int $caseID, string $comment = 'false', int $executionID = 0, string $from = 'testcase') { $oldCase = $this->testcase->getByID($caseID); - if(!$oldCase) return $this->send(array('result' => 'fail', 'callback' => "zui.Modal.alert('{$this->lang->notFound}')", 'load' => array('back' => true))); + if(!$oldCase) return $this->send(array('result' => 'fail', 'callback' => "zui.Modal.alert('{$this->lang->notFound}')", 'load' => array('back' => true), 'message' => $this->lang->testcase->noCase)); $testtasks = $this->loadModel('testtask')->getGroupByCases($caseID); $testtasks = empty($testtasks[$caseID]) ? array() : $testtasks[$caseID]; @@ -805,6 +805,9 @@ class testcase extends control */ public function delete(int $caseID) { + $case = $this->testcase->getByID($caseID); + if(!$case) return $this->send(array('result' => 'fail', 'message' => $this->lang->testcase->noCase)); + $this->testcase->delete(TABLE_CASE, $caseID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -813,7 +816,6 @@ class testcase extends control if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - $case = $this->testcase->getByID($caseID); $locateLink = $this->session->caseList ? $this->session->caseList : inlink('browse', "productID={$case->product}"); return $this->send(array('result' => 'success', 'message' => $message, 'load' => $locateLink)); }