From 101832bcfdb016b9c0b721eeaa26d9898bb45ec0 Mon Sep 17 00:00:00 2001 From: estellbright <1457749147@qq.com> Date: Sat, 28 Apr 2018 10:18:46 +0800 Subject: [PATCH] * Fix Bug #1518. --- module/file/control.php | 4 +++- module/testcase/model.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/module/file/control.php b/module/file/control.php index 3dbdaf656b..6f0c7706e7 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -306,7 +306,9 @@ class file extends control $file = $this->file->getById($fileID); $this->dao->delete()->from(TABLE_FILE)->where('id')->eq($fileID)->exec(); $this->loadModel('action')->create($file->objectType, $file->objectID, 'deletedFile', '', $extra=$file->title); - @unlink($file->realPath); + /* Fix Bug #1518. */ + $fileRecord = $this->dao->select('id')->from(TABLE_FILE)->where('pathname')->eq($file->pathname)->fetch(); + if(empty($fileRecord)) @unlink($file->realPath); die(js::reload('parent')); } } diff --git a/module/testcase/model.php b/module/testcase/model.php index 44abd24669..99d7328eef 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -1221,6 +1221,17 @@ class testcaseModel extends model $this->dao->insert(TABLE_CASESTEP)->data($step)->exec(); } } + /* Fix bug #1518. */ + $oldFile = $this->dao->select('*')->from(TABLE_FILE)->where('objectID')->eq($case->fromCaseID)->fetchAll(); + foreach($oldFile as $fileID => $File) + { + $File->objectID = $caseID; + $File->addedBy = $this->app->user->account; + $File->addedDate = helper::today(); + $File->downloads = 0; + unset($File->id); + $this->dao->insert(TABLE_FILE)->data($File)->exec(); + } $this->loadModel('action')->create('case', $caseID, 'fromlib', '', $case->lib); } }