diff --git a/module/bug/tao.php b/module/bug/tao.php
index 85452bf575..b9248ff9b2 100644
--- a/module/bug/tao.php
+++ b/module/bug/tao.php
@@ -228,7 +228,7 @@ class bugTao extends bugModel
* @access protected
* @return bool
*/
- protected function updateLinkBug(string $bugID, string $linkBug, string $oldLinkBug): bool
+ protected function updateLinkBug(int $bugID, string $linkBug, string $oldLinkBug): bool
{
$linkBugs = explode(',', $linkBug);
$oldLinkBugs = explode(',', $oldLinkBug);
@@ -242,15 +242,17 @@ class bugTao extends bugModel
if(in_array($changedBugID, $addedLinkBugs))
{
$currentLinkBug = $bugID;
- if(!empty($linkBugs)) $currentLinkBug = trim($linkBugs, ',') . ',' . $bugID;
+ $linkBugs = explode(',', $linkBugs);
+ if(!empty($linkBugs) && !in_array($bugID, $linkBugs)) $linkBugs[] = $bugID;
}
else
{
$linkBugs = explode(',', $linkBugs);
unset($linkBugs[array_search($bugID, $linkBugs)]);
- $currentLinkBug = implode(',', $linkBugs);
}
+ $currentLinkBug = implode(',', array_filter($linkBugs));
+
$this->dao->update(TABLE_BUG)->set('linkBug')->eq($currentLinkBug)->where('id')->eq($changedBugID)->exec();
}
diff --git a/module/bug/test/tao/data/sql/bug.sql b/module/bug/test/tao/data/sql/bug.sql
index 1d3a6228de..be592d58e5 100644
--- a/module/bug/test/tao/data/sql/bug.sql
+++ b/module/bug/test/tao/data/sql/bug.sql
@@ -117,4 +117,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2023-05-08 8:07:31
+-- Dump completed on 2023-05-08 10:24:51
diff --git a/module/bug/test/tao/data/sql/zt_bug_zd.sql b/module/bug/test/tao/data/sql/zt_bug_zd.sql
index 8f03f0d9a9..0d06c4e5ee 100755
--- a/module/bug/test/tao/data/sql/zt_bug_zd.sql
+++ b/module/bug/test/tao/data/sql/zt_bug_zd.sql
@@ -1,6 +1,6 @@
INSERT INTO zt_bug(`id`, `project`, `product`, `branch`, `module`, `execution`, `plan`, `story`, `storyVersion`, `task`, `toTask`, `toStory`, `title`, `keywords`, `severity`, `pri`, `type`, `os`, `browser`, `hardware`, `found`, `steps`, `status`, `subStatus`, `color`, `confirmed`, `activatedCount`, `mailto`, `openedBy`, `openedDate`, `openedBuild`, `assignedTo`, `assignedDate`, `deadline`, `resolvedBy`, `resolution`, `resolvedBuild`, `resolvedDate`, `closedBy`, `closedDate`, `duplicateBug`, `linkBug`, `case`, `caseVersion`, `result`, `repo`, `entry`, `lines`, `v1`, `v2`, `repoType`, `testtask`, `lastEditedBy`, `lastEditedDate`, `deleted`)
- VALUES ('1', '0', '1', '0', '1821', '0', '1', '2', '1', '0', '0', '0', 'BUG1', '', '3', '3', 'codeerror', '', '', '', '', '
【步骤】
【结果】
【期望】
', 'active', '', '#3da7f5', '0', '0', 'admin', 'admin', '2023-04-08 08:07:30', '1', 'admin', '2023-04-08', '2023-04-08', '', '', '', '2023-05-15', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
- ('2', '1', '2', '1', '1822', '1', '1', '6', '1', '0', '0', '0', 'BUG2', '', '3', '3', 'codeerror', '', '', '', '', '【步骤】进入成果展示
【结果】乱码
【期望】正常显示
', 'active', '', '#75c941', '1', '0', 'admin', 'admin', '2023-04-09 08:07:30', '2', 'admin', '2023-04-09', '2023-04-09', '', '', '', '2023-05-14', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
- ('3', '2', '3', '0', '1823', '2', '1', '10', '1', '0', '0', '0', 'BUG3', '', '3', '3', 'codeerror', 'win10', '', '', '', '【步骤】
【结果】
【期望】
', 'active', '', '#2dbdb2', '0', '0', 'admin', 'admin', '2023-04-10 08:07:30', '3', 'admin', '2023-04-10', '2023-04-10', '', '', '', '2023-05-13', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
- ('4', '3', '4', '1', '1825', '3', '4', '14', '1', '0', '0', '0', 'BUG4', '', '3', '3', 'codeerror', 'windows', '', '', '', '【步骤】进入成果展示
【结果】乱码
【期望】正常显示
', 'active', '', '#797ec9', '1', '0', 'admin', 'admin', '2023-04-11 08:07:30', '4', 'admin', '2023-04-11', '2023-04-11', '', '', '', '2023-05-12', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
- ('5', '4', '5', '0', '1826', '4', '4', '18', '1', '0', '0', '0', 'BUG5', '', '3', '3', 'codeerror', 'android', '', '', '', '【步骤】
【结果】
【期望】
', 'active', '', '#ffaf38', '0', '0', 'admin', 'admin', '2023-04-12 08:07:30', '5', 'admin', '2023-04-12', '2023-04-12', '', '', '', '2023-05-11', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0');
+ VALUES ('1', '0', '1', '0', '1821', '0', '1', '2', '1', '0', '0', '0', 'BUG1', '', '3', '3', 'codeerror', '', '', '', '', '【步骤】
【结果】
【期望】
', 'active', '', '#3da7f5', '0', '0', 'admin', 'admin', '2023-04-08 10:24:51', '1', 'admin', '2023-04-08', '2023-04-08', '', '', '', '2023-05-15', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
+ ('2', '1', '2', '1', '1822', '1', '1', '6', '1', '0', '0', '0', 'BUG2', '', '3', '3', 'codeerror', '', '', '', '', '【步骤】进入成果展示
【结果】乱码
【期望】正常显示
', 'active', '', '#75c941', '1', '0', 'admin', 'admin', '2023-04-09 10:24:51', '2', 'admin', '2023-04-09', '2023-04-09', '', '', '', '2023-05-14', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
+ ('3', '2', '3', '0', '1823', '2', '1', '10', '1', '0', '0', '0', 'BUG3', '', '3', '3', 'codeerror', 'win10', '', '', '', '【步骤】
【结果】
【期望】
', 'active', '', '#2dbdb2', '0', '0', 'admin', 'admin', '2023-04-10 10:24:51', '3', 'admin', '2023-04-10', '2023-04-10', '', '', '', '2023-05-13', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
+ ('4', '3', '4', '1', '1825', '3', '4', '14', '1', '0', '0', '0', 'BUG4', '', '3', '3', 'codeerror', 'windows', '', '', '', '【步骤】进入成果展示
【结果】乱码
【期望】正常显示
', 'active', '', '#797ec9', '1', '0', 'admin', 'admin', '2023-04-11 10:24:51', '4', 'admin', '2023-04-11', '2023-04-11', '', '', '', '2023-05-12', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0'),
+ ('5', '4', '5', '0', '1826', '4', '4', '18', '1', '0', '0', '0', 'BUG5', '', '3', '3', 'codeerror', 'android', '', '', '', '【步骤】
【结果】
【期望】
', 'active', '', '#ffaf38', '0', '0', 'admin', 'admin', '2023-04-12 10:24:51', '5', 'admin', '2023-04-12', '2023-04-12', '', '', '', '2023-05-11', '', '', '0', '', '0', '0', '0', '0', '', '', '', '', '', '0', '', '', '0');
diff --git a/module/bug/test/tao/updatelinkbug.php b/module/bug/test/tao/updatelinkbug.php
index 9832954679..08ceaa8daa 100755
--- a/module/bug/test/tao/updatelinkbug.php
+++ b/module/bug/test/tao/updatelinkbug.php
@@ -28,16 +28,26 @@ title=bugModel->updateLinkBug();
timeout=0
cid=1
+- 测试关联bug2的关联bug同步更新为1属性2 @1
+
+- 测试关联bug2的关联bug同步更新为空,bug3的关联bug为1
+ - 属性2 @~~
+ - 属性3 @1
+
+- 测试关联bug2的关联bug同步更新为1属性2 @1
+
+- 测试关联bug3的关联bug同步更新为1,2属性3 @1,2
+
*/
initData();
-$bugIDList = array('1', '2', '3');
+$bugIDList = array(1, 2, 3);
$bug = new bugTest();
-r($bug->updateLinkBugTest($bugIDList[0], '2', '')) && p('2') && r('1'); //测试关联bug2的关联bug同步更新为1 2:1
-r($bug->updateLinkBugTest($bugIDList[0], '3', '2')) && p('2;3') && r("'';1"); //测试关联bug2的关联bug同步更新为空,bug3的关联bug为2
-r($bug->updateLinkBugTest($bugIDList[0], '2,3', '3')) && p('2;3') && r('1;1'); //测试关联bug2的关联bug同步更新为1,bug3的关联bug为1
-r($bug->updateLinkBugTest($bugIDList[1], '1,3', '1')) && p('3') && r('1,2'); //测试关联bug3的关联bug同步更新为1,2
\ No newline at end of file
+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