From 062bb522f0334f19605c30de54cd05525150f556 Mon Sep 17 00:00:00 2001 From: daitingting Date: Tue, 9 May 2023 01:52:46 +0000 Subject: [PATCH 1/2] * Optimize codes. --- module/bug/control.php | 2 +- module/bug/tao.php | 4 ++-- module/bug/test/bug.class.php | 2 +- module/bug/test/tao/updatelinkbug.php | 4 ++-- module/file/model.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index bb5d4898f3..b9afda08b7 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -680,7 +680,7 @@ class bug extends control if(!$comment) { $changes = $this->bug->update($bug, $oldBug); - if(!$changes) return $this->send($this->bugZen->errorEdit()); + if($changes === false) return $this->send($this->bugZen->errorEdit()); } $this->bugZen->processAfterEdit($bugID, $this->post->comment, $changes); diff --git a/module/bug/tao.php b/module/bug/tao.php index b9248ff9b2..3a732da0f3 100644 --- a/module/bug/tao.php +++ b/module/bug/tao.php @@ -222,13 +222,13 @@ class bugTao extends bugModel * 更新相关bug。 * Update the linked bug. * - * @param int $bugID + * @param string $bugID * @param string $linkBug * @param string $oldLinkBug * @access protected * @return bool */ - protected function updateLinkBug(int $bugID, string $linkBug, string $oldLinkBug): bool + protected function updateLinkBug(string $bugID, string $linkBug, string $oldLinkBug): bool { $linkBugs = explode(',', $linkBug); $oldLinkBugs = explode(',', $oldLinkBug); diff --git a/module/bug/test/bug.class.php b/module/bug/test/bug.class.php index d494431892..ff16c6930e 100644 --- a/module/bug/test/bug.class.php +++ b/module/bug/test/bug.class.php @@ -2156,7 +2156,7 @@ class bugTest $allRelatedLinkBugs = array_merge($addedLinkBugs, $removedLinkBugs, array($bugID)); global $tester; - $linkBugPairs = $tester->dao->select('id,linkBug')->from(TABLE_BUG)->where('id')->in(array_filter($allRelatedLinkBugs))->andWhere('deleted')->eq('0')->fetchPairs(); + $linkBugPairs = $tester->dao->select('id, linkBug')->from(TABLE_BUG)->where('id')->in(array_filter($allRelatedLinkBugs))->andWhere('deleted')->eq('0')->fetchPairs(); if(dao::isError()) return dao::getError(); return $linkBugPairs; diff --git a/module/bug/test/tao/updatelinkbug.php b/module/bug/test/tao/updatelinkbug.php index 08ceaa8daa..2e3ec64be5 100755 --- a/module/bug/test/tao/updatelinkbug.php +++ b/module/bug/test/tao/updatelinkbug.php @@ -44,10 +44,10 @@ cid=1 initData(); -$bugIDList = array(1, 2, 3); +$bugIDList = array('1', '2', '3'); $bug = new bugTest(); r($bug->updateLinkBugTest($bugIDList[0], '2', '')) && p('2', ';') && e('1'); //测试关联bug2的关联bug同步更新为1 r($bug->updateLinkBugTest($bugIDList[0], '3', '2')) && p('2;3', ';') && e('~~;1'); //测试关联bug2的关联bug同步更新为空,bug3的关联bug为1 r($bug->updateLinkBugTest($bugIDList[0], '2,3', '3')) && p('2') && e('1'); //测试关联bug2的关联bug同步更新为1 -r($bug->updateLinkBugTest($bugIDList[1], '1,3', '1')) && p('3', ';') && e('1,2'); //测试关联bug3的关联bug同步更新为1,2 \ No newline at end of file +r($bug->updateLinkBugTest($bugIDList[1], '1,3', '1')) && p('3', ';') && e('1,2'); //测试关联bug3的关联bug同步更新为1,2 diff --git a/module/file/model.php b/module/file/model.php index 78a93bf5e8..b3e6c6a869 100755 --- a/module/file/model.php +++ b/module/file/model.php @@ -1183,7 +1183,7 @@ class fileModel extends model */ public function processFile4Object($objectType, $oldObject, $newObject, $extra = '', $filesName = 'files', $labelsName = 'labels') { - $oldFiles = empty($oldObject->files) ? '' : join(',', array_keys($oldObject->files)); + $oldFiles = empty($oldObject->files) ? '' : implode(',', array_keys($oldObject->files)); $deleteFiles = $newObject->deleteFiles; if(!empty($deleteFiles)) { From 0f508687afe448ba9453288b392f52e8f2ff436d Mon Sep 17 00:00:00 2001 From: daitingting Date: Tue, 9 May 2023 05:11:37 +0000 Subject: [PATCH 2/2] * Format codes. --- module/bug/test/bug.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/bug/test/bug.class.php b/module/bug/test/bug.class.php index ff16c6930e..6d0da632ab 100644 --- a/module/bug/test/bug.class.php +++ b/module/bug/test/bug.class.php @@ -2156,7 +2156,10 @@ class bugTest $allRelatedLinkBugs = array_merge($addedLinkBugs, $removedLinkBugs, array($bugID)); global $tester; - $linkBugPairs = $tester->dao->select('id, linkBug')->from(TABLE_BUG)->where('id')->in(array_filter($allRelatedLinkBugs))->andWhere('deleted')->eq('0')->fetchPairs(); + $linkBugPairs = $tester->dao->select('id, linkBug')->from(TABLE_BUG) + ->where('id')->in(array_filter($allRelatedLinkBugs)) + ->andWhere('deleted')->eq('0') + ->fetchPairs(); if(dao::isError()) return dao::getError(); return $linkBugPairs;