diff --git a/config/config.php b/config/config.php index 8838e14be4..1708d8e67f 100644 --- a/config/config.php +++ b/config/config.php @@ -170,10 +170,9 @@ $config->allowedTags = '
$config->accountRule = '|^[a-zA-Z0-9_]{1}[a-zA-Z0-9_\.]{1,}[a-zA-Z0-9_]{1}$|';
$config->checkVersion = true; // Auto check for new version or not.
-/* Set the wide window size and timeout(ms) and duplicate interval time(s). */
+/* Set the wide window size and timeout(ms). */
$config->wideSize = 1400;
$config->timeout = 30000;
-$config->duplicateTime = 30;
$config->maxCount = 500;
$config->moreLinks = array();
diff --git a/module/bug/control.php b/module/bug/control.php
index ec0101fa2d..24ea1c546e 100755
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -251,8 +251,6 @@ class bug extends control
$formData = form::data($this->config->bug->form->create);
$bug = $this->bugZen->prepareCreateExtras($formData);
- $this->bugZen->checkExistBug($bug);
-
$bugID = $this->bug->create($bug, $from);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
diff --git a/module/bug/zen.php b/module/bug/zen.php
index 90c5a8afe4..496e249fc4 100644
--- a/module/bug/zen.php
+++ b/module/bug/zen.php
@@ -2,27 +2,6 @@
declare(strict_types=1);
class bugZen extends bug
{
- /**
- * 检查bug是否已经存在。
- * Check whether bug is exist.
- *
- * @param object $bug
- * @access protected
- * @return bool
- */
- protected function checkExistBug(object $bug): bool
- {
- $result = $this->loadModel('common')->removeDuplicate('bug', $bug, "product={$bug->product}");
-
- if($result && $result['stop'])
- {
- $message = sprintf($this->lang->duplicate, $this->lang->bug->common);
- return $this->send(array('result' => 'success', 'message' => $message, 'load' => $this->createLink('bug', 'view', "bugID={$result['duplicate']}")));
- }
-
- return true;
- }
-
/**
* 检查用户是否拥有所属执行的权限。
* Check bug execution priv.
@@ -147,19 +126,6 @@ class bugZen extends bug
*/
protected function checkBugsForBatchCreate(array $bugs, int $productID): array
{
- $this->loadModel('common');
-
- /* Check whether the bugs meet the requirements, and if not, remove it. */
- foreach($bugs as $index => $bug)
- {
- $result = $this->common->removeDuplicate('bug', $bug, "product={$productID}");
- if(zget($result, 'stop', false) !== false)
- {
- unset($bugs[$index]);
- continue;
- }
- }
-
/* Check required fields. */
foreach($bugs as $index => $bug)
{
diff --git a/module/caselib/control.php b/module/caselib/control.php
index 380b12a98c..9557f802bd 100644
--- a/module/caselib/control.php
+++ b/module/caselib/control.php
@@ -248,9 +248,6 @@ class caselib extends control
}
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
- $result = $this->loadModel('common')->removeDuplicate('case', $case, "id!='$param'");
- if($result and $result['stop']) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->duplicate, $this->lang->testcase->common), 'locate' => $this->createLink('testcase', 'view', "caseID={$result['duplicate']}")));
-
$this->testcase->create($case);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
diff --git a/module/caselib/zen.php b/module/caselib/zen.php
index fd18ea20a2..277c9951f2 100644
--- a/module/caselib/zen.php
+++ b/module/caselib/zen.php
@@ -153,13 +153,6 @@ class caselibZen extends caselib
$testcases = form::batchData($this->config->testcase->form->batchCreate)->get();
foreach($testcases as $i => $testcase)
{
- $result = $this->common->removeDuplicate('testcase', $testcase, "lib={$libID}");
- if(zget($result, 'stop', false) !== false)
- {
- unset($testcases[$i]);
- continue;
- }
-
$testcase->lib = $libID;
$testcase->project = 0;
$testcase->openedBy = $account;
diff --git a/module/common/model.php b/module/common/model.php
index e883c61bd2..34f83cf79f 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -1059,50 +1059,6 @@ class commonModel extends model
$this->session->set($objectType . 'BrowseList', array(), $this->app->tab);
}
- /**
- * 批量创建时,移除名称重复的对象。
- * Remove duplicate for story, task, bug, case, doc.
- *
- * @param string $type e.g. story task bug case doc.
- * @param array|object $data
- * @param string $condition
- * @access public
- * @return array|false
- */
- public function removeDuplicate(string $type, object|array $data, string $condition = ''): array|false
- {
- $table = zget($this->config->objectTables, $type, '');
- if(empty($table)) return array('stop' => false, 'data' => $data);
-
- $titleField = $type == 'task' ? 'name' : 'title';
- $date = date(DT_DATETIME1, time() - $this->config->duplicateTime);
- $dateField = $type == 'doc' ? 'addedDate' : 'openedDate';
- $titles = zget($data, $titleField, array());
- $storyType = zget($data, 'type', '');
-
- if(empty($titles)) return false;
- $duplicate = $this->dao->select("id,$titleField")->from($table)
- ->where('deleted')->eq(0)
- ->andWhere($titleField)->in($titles)
- ->andWhere($dateField)->ge($date)->fi()
- ->beginIF($condition)->andWhere($condition)->fi()
- ->beginIF($type == 'story')->andWhere('type')->eq($storyType)
- ->fetchPairs();
-
- if($duplicate and is_string($titles)) return array('stop' => true, 'duplicate' => key($duplicate));
- if($duplicate and is_array($titles))
- {
- foreach($titles as $i => $title)
- {
- if(in_array($title, $duplicate)) unset($titles[$i]);
- }
-
- if(is_object($data)) $data->$titleField = $titles;
- if(is_array($data)) $data[$titleField] = $titles;
- }
- return array('stop' => false, 'data' => $data);
- }
-
/**
* 追加排序字段。
* Append order by.
diff --git a/module/common/test/model/removeduplicate.php b/module/common/test/model/removeduplicate.php
deleted file mode 100755
index 6bbafc1f28..0000000000
--- a/module/common/test/model/removeduplicate.php
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/bin/env php
-id->range('1');
-$story->title->range('teststory');
-$story->gen(1);
-
-$case = zenData('case');
-$case->id->range('1');
-$case->title->range('testcase');
-$case->gen(1);
-
-$task = zenData('task');
-$task->id->range('1');
-$task->name->range('testtask');
-$task->gen(1);
-
-$bug = zenData('bug');
-$bug->id->range('1');
-$bug->title->range('testbug');
-$bug->gen(1);
-
-$doc = zenData('doc');
-$doc->id->range('1');
-$doc->title->range('testdoc');
-$doc->gen(1);
-
-/**
-
-title=测试 commonModel->removeDuplicate();
-timeout=0
-cid=1
-
-- 测试是否是重复需求
- - 属性stop @1
- - 属性duplicate @1
-- 有条件情况下,测试是否是重复需求。属性stop @~~
-- 测试是否是重复用例
- - 属性stop @1
- - 属性duplicate @1
-- 有条件情况下,测试是否是重复用例。属性stop @~~
-- 测试是否是重复任务
- - 属性stop @1
- - 属性duplicate @1
-- 有条件情况下,测试是否是重复用例。属性stop @~~
-- 测试是否是重复Bug
- - 属性stop @1
- - 属性duplicate @1
-- 有条件情况下,测试是否是重复Bug属性stop @~~
-- 测试是否是重复文档
- - 属性stop @1
- - 属性duplicate @1
-- 有条件情况下,测试是否是重复文档属性stop @~~
-- 测试批量重复需求 @story1
-- 有条件情况下,测试批量重复需求 @2
-- 测试批量重复用例 @case1
-- 有条件情况下,测试批量重复用例 @2
-- 测试批量重复任务 @task1
-- 有条件情况下,测试批量重复任务 @2
-- 测试批量重复Bug @bug1
-- 有条件情况下,测试批量重复Bug @2
-- 测试批量重复文档 @doc1
-- 有条件情况下,测试批量重复文档 @2
-
-*/
-
-global $tester;
-$tester->loadModel('common');
-
-$now = date('Y-m-d H:i:s', time() - 5);
-$tester->common->dao->update(TABLE_STORY)->set('openedDate')->eq($now)->exec();
-$tester->common->dao->update(TABLE_CASE)->set('openedDate')->eq($now)->exec();
-$tester->common->dao->update(TABLE_TASK)->set('openedDate')->eq($now)->exec();
-$tester->common->dao->update(TABLE_BUG)->set('openedDate')->eq($now)->exec();
-$tester->common->dao->update(TABLE_DOC)->set('addedDate')->eq($now)->exec();
-
-$story = new stdclass();
-$story->title = 'teststory';
-$story->type = 'requirement';
-r($tester->common->removeDuplicate('story', $story)) && p('stop,duplicate') && e('1,1'); //测试是否是重复需求
-r($tester->common->removeDuplicate('story', $story, 'id!=1')) && p('stop') && e('~~'); //有条件情况下,测试是否是重复需求。
-
-$case = new stdclass();
-$case->title = 'testcase';
-r($tester->common->removeDuplicate('case', $case)) && p('stop,duplicate') && e('1,1'); //测试是否是重复用例
-r($tester->common->removeDuplicate('case', $case, 'id!=1')) && p('stop') && e('~~'); //有条件情况下,测试是否是重复用例。
-
-$task = new stdclass();
-$task->name = 'testtask';
-r($tester->common->removeDuplicate('task', $task)) && p('stop,duplicate') && e('1,1'); //测试是否是重复任务
-r($tester->common->removeDuplicate('task', $task, 'id!=1')) && p('stop') && e('~~'); //有条件情况下,测试是否是重复用例。
-
-$bug = new stdclass();
-$bug->title = 'testbug';
-r($tester->common->removeDuplicate('bug', $bug)) && p('stop,duplicate') && e('1,1'); //测试是否是重复Bug
-r($tester->common->removeDuplicate('bug', $bug, 'id!=1')) && p('stop') && e('~~'); //有条件情况下,测试是否是重复Bug
-
-$doc = new stdclass();
-$doc->title = 'testdoc';
-r($tester->common->removeDuplicate('doc', $doc)) && p('stop,duplicate') && e('1,1'); //测试是否是重复文档
-r($tester->common->removeDuplicate('doc', $doc, 'id!=1')) && p('stop') && e('~~'); //有条件情况下,测试是否是重复文档
-
-$story = new stdclass();
-$story->title = array('teststory', 'story1');
-$result = $tester->common->removeDuplicate('story', $story);
-r($result['data']->title[1]) && p() && e('story1'); //测试批量重复需求
-
-$story->title = array('teststory', 'story1');
-$result = $tester->common->removeDuplicate('story', $story, 'id!=1');
-r(count($result['data']->title)) && p() && e('2'); //有条件情况下,测试批量重复需求
-
-$case = new stdclass();
-$case->title = array('testcase', 'case1');
-$result = $tester->common->removeDuplicate('case', $case);
-r($result['data']->title[1]) && p() && e('case1'); //测试批量重复用例
-
-$case->title = array('testcase', 'case1');
-$result = $tester->common->removeDuplicate('case', $case, 'id!=1');
-r(count($result['data']->title)) && p() && e('2'); //有条件情况下,测试批量重复用例
-
-$task = new stdclass();
-$task->name = array('testtask', 'task1');
-$result = $tester->common->removeDuplicate('task', $task);
-r($result['data']->name[1]) && p() && e('task1'); //测试批量重复任务
-
-$task->name = array('testtask', 'task1');
-$result = $tester->common->removeDuplicate('task', $task, 'id!=1');
-r(count($result['data']->name)) && p() && e('2'); //有条件情况下,测试批量重复任务
-
-$bug = new stdclass();
-$bug->title = array('testbug', 'bug1');
-$result = $tester->common->removeDuplicate('bug', $bug);
-r($result['data']->title[1]) && p() && e('bug1'); //测试批量重复Bug
-
-$bug->title = array('testbug', 'bug1');
-$result = $tester->common->removeDuplicate('bug', $bug, 'id!=1');
-r(count($result['data']->title)) && p() && e('2'); //有条件情况下,测试批量重复Bug
-
-$doc = new stdclass();
-$doc->title = array('testdoc', 'doc1');
-$result = $tester->common->removeDuplicate('doc', $doc);
-r($result['data']->title[1]) && p() && e('doc1'); //测试批量重复文档
-
-$doc->title = array('testdoc', 'doc1');
-$result = $tester->common->removeDuplicate('doc', $doc, 'id!=1');
-r(count($result['data']->title)) && p() && e('2'); //有条件情况下,测试批量重复文档
diff --git a/module/story/control.php b/module/story/control.php
index b8ffa115cb..d71c1818ca 100755
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -70,9 +70,6 @@ class story extends control
$storyData = $this->storyZen->buildStoryForCreate($objectID, $bugID, $storyType);
if(!$storyData) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
- $response = $this->storyZen->checkRepeatStory($storyData, $objectID);
- if($response) return $this->send($response);
-
/* Insert story data. */
$createFunction = empty($storyData->branches) ? 'create' : 'createTwins';
$storyID = $this->story->{$createFunction}($storyData, $objectID, $bugID, $extra, $todoID);
@@ -144,9 +141,6 @@ class story extends control
if(!empty($_POST))
{
- $result = $this->loadModel('common')->removeDuplicate('story', $_POST, "product={$productID}");
- $_POST = $result['data'];
-
$stories = $this->storyZen->buildStoriesForBatchCreate($productID, $storyType);
if(empty($stories)) return $this->sendError($this->lang->story->errorEmptyStory, true);
if(dao::isError()) return $this->sendError(dao::getError());
diff --git a/module/story/zen.php b/module/story/zen.php
index 0d2fb62929..a1cb6caa84 100644
--- a/module/story/zen.php
+++ b/module/story/zen.php
@@ -1645,37 +1645,6 @@ class storyZen extends story
return $stories;
}
- /**
- * 检查需求是否重复。
- * Check repeat story.
- *
- * @param object $story
- * @param int $objectID
- * @param string $storyType
- * @access protected
- * @return array
- */
- protected function checkRepeatStory(object $story, int $objectID, string $storyType = 'story'): array
- {
- /* Check repeat story. */
- $result = $this->loadModel('common')->removeDuplicate('story', $story, "product={$story->product}");
- if(empty($result['stop'])) return array();
-
- $response['result'] = 'success';
- $response['message'] = sprintf($this->lang->duplicate, $this->lang->story->common);
- $response['locate'] = $this->createLink('story', 'view', "storyID={$result['duplicate']}&version=0¶m=0&storyType=$storyType");
- $response['closeModal'] = true;
- if($objectID)
- {
- $execution = $this->dao->findById((int)$objectID)->from(TABLE_EXECUTION)->fetch();
- $moduleName = $execution->type == 'project' ? 'projectstory' : 'execution';
- $param = $execution->type == 'project' ? "projectID=$objectID&productID={$story->product}" : "executionID=$objectID";
- $response['locate'] = $this->createLink($moduleName, 'story', $param);
- }
-
- return $response;
- }
-
/**
* 如果是在弹窗中打开页面,获取跳转地址。
* Get response when open in modal.
diff --git a/module/task/control.php b/module/task/control.php
index 77f87bb402..cc8179ac7f 100755
--- a/module/task/control.php
+++ b/module/task/control.php
@@ -65,10 +65,6 @@ class task extends control
$taskData = $this->taskZen->buildTaskForCreate($this->post->execution ? (int)$this->post->execution : $executionID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
- /* Check whether a task with the same name is created within the specified time. */
- $duplicateTaskID = $this->taskZen->checkDuplicateName($taskData);
- if($duplicateTaskID) return $this->send(array('result' => 'success', 'message' => sprintf($this->lang->duplicate, $this->lang->task->common), 'load' => $this->createLink('task', 'view', "taskID={$duplicateTaskID}")));
-
$this->dao->begin();
if($this->post->type == 'test' && $this->post->selectTestStory == 'on')
{
diff --git a/module/task/zen.php b/module/task/zen.php
index 5a64a353ab..36c66d88a9 100644
--- a/module/task/zen.php
+++ b/module/task/zen.php
@@ -650,10 +650,6 @@ class taskZen extends task
if($task->assignedTo) $task->assignedDate = helper::now();
}
- /* Remove data with the same task name. */
- $tasks = $this->removeDuplicateForBatchCreate($execution->id, $tasks);
- if(dao::isError()) return false;
-
/* Check if the input post data meets the requirements. */
$this->checkBatchCreateTask($execution->id, $tasks);
if(dao::isError()) return false;
@@ -1144,24 +1140,6 @@ class taskZen extends task
return !dao::isError();
}
- /**
- * 检查规定时间内是否创建了同名任务。
- * Check whether a task with the same name is created within the specified time.
- *
- * @param object $task
- * @access protected
- * @return int
- */
- protected function checkDuplicateName($task): int
- {
- /* Check duplicate task. */
- if($task->type == 'affair' || !$task->name) return 0;
- $sql = "execution={$task->execution} AND story=" . (int)$task->story . (isset($task->feedback) ? " AND feedback=" . (int)$task->feedback : '');
- $result = $this->loadModel('common')->removeDuplicate('task', $task, $sql);
- if($result['stop']) return zget($result, 'duplicate', 0);
- return 0;
- }
-
/**
* 检查关联需求的测试类型任务数据格式是否符合要求。
* Check if the test type task data format of the linked stories meets the requirements.
@@ -1911,55 +1889,6 @@ class taskZen extends task
return $response;
}
- /**
- * 在批量创建之前移除post数据中重复的数据。
- * Remove the duplicate data before batch create tasks.
- *
- * @param int $executionID
- * @param array $tasks
- * @access protected
- * @return array
- */
- protected function removeDuplicateForBatchCreate(int $executionID, array $tasks): array
- {
- /* 1. 检查表单是否有重复。 Check duplicate in form data. */
- $duplicateTasks = array();
- $storyIdList = array();
- foreach($tasks as $rowIndex => $task)
- {
- if(empty($task->story)) continue;
-
- /* 事务型任务可能有多个指派人,不需要检查是否重名。 Tasks of Affair type no need to check duplicate name. */
- if($task->type == 'affair') continue;
-
- /* 表单的任务名称+不能有重复。 The name of post tasks must be unique. */
-
- /* 检查Post传过来的任务有没有重复数据,不能有相同需求的同名任务。 Check whether the post tasks have duplicate data. */
- $duplicateKey = (string)$task->story . '-' . $task->name;
- if(isset($duplicateTasks[$duplicateKey]))
- {
- dao::$errors["name[$rowIndex]"] = sprintf($this->lang->duplicate, $this->lang->task->common) . ' ' . $task->name;
- return array();
- }
- $duplicateTasks[$duplicateKey] = array('rowIndex' => $rowIndex, 'name' => $task->name);
- $storyIdList[$task->story] = $task->story;
- }
-
- /* 2. 检查数据库是否有重复数据。 Check duplicate in db. */
- $existTasks = $this->task->getListByStories($storyIdList, $executionID);
- foreach($existTasks as $task)
- {
- $duplicateKey = (string)$task->story . '-' . $task->name;
- if(isset($duplicateTasks[$duplicateKey]))
- {
- $rowIndex = $duplicateTasks[$duplicateKey]['rowIndex'];
- unset($tasks[$rowIndex]);
- }
- }
-
- return $tasks;
- }
-
/**
* 通过传入的对象ID设置任务信息。
* Set task through the input object ID.
diff --git a/module/testcase/zen.php b/module/testcase/zen.php
index 2ed090c546..cbb0ee591b 100755
--- a/module/testcase/zen.php
+++ b/module/testcase/zen.php
@@ -1880,11 +1880,6 @@ class testcaseZen extends testcase
if(!empty($case->lib)) $param = "lib={$case->lib}";
if(!empty($case->product)) $param = "product={$case->product}";
- $result = $this->loadModel('common')->removeDuplicate('case', $case, $param);
- if($result && $result['stop'])
- {
- return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->duplicate, $this->lang->testcase->common), 'load' => $this->createLink('testcase', 'view', "caseID={$result['duplicate']}")));
- }
return true;
}
@@ -1903,15 +1898,6 @@ class testcaseZen extends testcase
$requiredErrors = array();
foreach($testcases as $i => $testcase)
{
- /* 检查重复项。 */
- /* Check duplicate. */
- $result = $this->common->removeDuplicate('testcase', $testcase, "product={$productID}");
- if(zget($result, 'stop', false) !== false)
- {
- unset($testcases[$i]);
- continue;
- }
-
/* 检验必填项。 */
/* Check reuqired. */
foreach(explode(',', $this->config->testcase->create->requiredFields) as $field)