diff --git a/module/bug/config/form.php b/module/bug/config/form.php index 4663a2cc2b..1268a54878 100644 --- a/module/bug/config/form.php +++ b/module/bug/config/form.php @@ -93,6 +93,7 @@ $config->bug->form->assignTo['mailto'] = array('required' => false, 'typ $config->bug->form->resolve = array(); $config->bug->form->resolve['status'] = array('required' => false, 'type' => 'string', 'default' => 'resolved'); +$config->bug->form->resolve['confirmed'] = array('required' => false, 'type' => 'int', 'default' => 1); $config->bug->form->resolve['resolvedBuild'] = array('required' => false, 'type' => 'int', 'default' => 0); $config->bug->form->resolve['resolution'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->bug->form->resolve['resolvedBy'] = array('required' => false, 'type' => 'string', 'default' => $app->user->account); @@ -105,8 +106,6 @@ $config->bug->form->resolve['duplicateBug'] = array('required' => false, 'type $config->bug->form->resolve['buildName'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->bug->form->resolve['createBuild'] = array('required' => false, 'type' => 'int', 'default' => 0); $config->bug->form->resolve['buildExecution'] = array('required' => false, 'type' => 'int', 'default' => 0); -$config->bug->form->resolve['comment'] = array('required' => false, 'type' => 'string', 'default' => ''); -$config->bug->form->resolve['uid'] = array('required' => false, 'type' => 'string', 'default' => ''); $config->bug->form->activate = array(); $config->bug->form->activate['assignedTo'] = array('required' => false, 'type' => 'string', 'default' => ''); diff --git a/module/bug/control.php b/module/bug/control.php index afcda5a5a8..5ab46ec8c9 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -411,8 +411,8 @@ class bug extends control public function resolve(int $bugID, string $extra = '') { /* Get old bug, and check privilege of the execution. */ - $bug = $this->bug->getById($bugID); - $this->bugZen->checkBugExecutionPriv($bug); + $oldBug = $this->bug->getById($bugID); + $this->bugZen->checkBugExecutionPriv($oldBug); if(!empty($_POST)) { @@ -421,38 +421,36 @@ class bug extends control parse_str($extra, $output); /* Init bug data. */ - $bug = $this->bugZen->buildBugForResolve($bug, (int)$this->post->uid); + $bug = $this->bugZen->buildBugForResolve($oldBug); - $changes = $this->bug->resolve($bug, $output); + /* Can create build when resolving bug. */ + if(!empty($bug->createBuild)) + { + $this->bug->createBuild($bug, $oldBug); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + } + + if($oldBug->status != 'closed') $changes = $this->bug->resolve($bug, $output); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $this->executeHooks($bug->id); - - /* Get response after resolving. */ - $regionID = zget($output, 'regionID', 0); + $regionID = !empty($output['regionID']) ? $output['regionID'] : 0; return $this->send($this->bugZen->responseAfterOperate($bugID, $changes, '', $regionID)); } - /* Get users who is not closed and get assigned person. */ - $users = $this->user->getPairs('noclosed'); - $assignedTo = $bug->openedBy; - if(!isset($users[$assignedTo])) $assignedTo = $this->bug->getModuleOwner($bug->module, $bug->product); - /* Remove 'Convert to story' from the solution list. */ unset($this->lang->bug->resolutionList['tostory']); /* Set menu. */ - $this->qa->setMenu($this->products, $bug->product, $bug->branch); + $this->qa->setMenu($this->products, $oldBug->product, $oldBug->branch); /* Show the variables associated. */ - $this->view->title = $this->products[$bug->product] . $this->lang->colon . $this->lang->bug->resolve; - $this->view->bug = $bug; - $this->view->users = $users; - $this->view->assignedTo = $assignedTo; - $this->view->executions = $this->loadModel('product')->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $bug->project, 'stagefilter'); - $this->view->builds = $this->loadModel('build')->getBuildPairs($bug->product, $bug->branch, 'withbranch,noreleased'); - $this->view->actions = $this->loadModel('action')->getList('bug', $bugID); - $this->view->execution = $bug->execution ? $this->loadModel('execution')->getByID($bug->execution) : ''; + $this->view->title = $this->products[$oldBug->product] . $this->lang->colon . $this->lang->bug->resolve; + $this->view->bug = $oldBug; + $this->view->execution = $oldBug->execution ? $this->loadModel('execution')->getByID($bug->execution) : ''; + $this->view->users = $this->user->getPairs('noclosed'); + $this->view->executions = $this->loadModel('product')->getExecutionPairsByProduct($oldBug->product, $oldBug->branch ? "0,{$oldBug->branch}" : 0, 'id_desc', $oldBug->project, 'stagefilter'); + $this->view->builds = $this->loadModel('build')->getBuildPairs($oldBug->product, $oldBug->branch, 'withbranch,noreleased'); + $this->view->actions = $this->loadModel('action')->getList('bug', $bugID); $this->display(); } diff --git a/module/bug/model.php b/module/bug/model.php index 427283269d..954982a37d 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -662,27 +662,18 @@ class bugModel extends model public function resolve(object $bug, array $output = array()): array|false { /* Get old bug. */ - $oldBug = $this->getById((int)$bug->id); - - /* If status of the bug is closed, skip it. */ - if($oldBug->status == 'closed') return false; - - /* Can create build when resolving bug. */ - if(!empty($bug->createBuild)) - { - $this->createBuild($bug, $oldBug); - if(dao::isError()) return false; - } + $oldBug = $this->getById($bug->id); /* Update bug. */ - $this->dao->update(TABLE_BUG)->data($bug, 'buildName,createBuild,buildExecution,comment,uid') + $this->dao->update(TABLE_BUG)->data($bug, 'buildName,createBuild,buildExecution') ->autoCheck() ->batchCheck($this->config->bug->resolve->requiredFields, 'notempty') ->checkIF($bug->resolution == 'duplicate', 'duplicateBug', 'notempty') ->checkIF($bug->resolution == 'fixed', 'resolvedBuild','notempty') ->checkFlow() - ->where('id')->eq((int)$bug->id) + ->where('id')->eq($bug->id) ->exec(); + if(dao::isError()) return false; /* Add score. */ @@ -701,9 +692,9 @@ class bugModel extends model /* Save files and record log. */ $files = $this->loadModel('file')->saveUpload('bug', $bug->id); $fileAction = !empty($files) ? $this->lang->addFiles . implode(',', $files) . "\n" : ''; - $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Resolved', $fileAction . $bug->comment, $bug->resolution . (isset($bug->duplicateBug) ? ':' . $bug->duplicateBug : '')); $changes = common::createChanges($oldBug, $bug); - $this->action->logHistory($actionID, $changes); + $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Resolved', $fileAction . $this->post->comment, $bug->resolution . (isset($bug->duplicateBug) ? ':' . $bug->duplicateBug : '')); + if($changes) $this->action->logHistory($actionID, $changes); /* If the edition is not pms, update feedback. */ if(($this->config->edition == 'biz' || $this->config->edition == 'max') && $oldBug->feedback) $this->loadModel('feedback')->updateStatus('bug', $oldBug->feedback, $bug->status, $oldBug->status); diff --git a/module/bug/zen.php b/module/bug/zen.php index 978e5e9337..779cb1e80d 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -1484,11 +1484,10 @@ class bugZen extends bug * Build bug for resolving a bug. * * @param object $oldBug - * @param int $uid * @access protected * @return object */ - protected function buildBugForResolve(object $oldBug, int $uid): object + protected function buildBugForResolve(object $oldBug): object { $bug = form::data($this->config->bug->form->resolve) ->setDefault('assignedTo', $oldBug->openedBy) @@ -1506,7 +1505,7 @@ class bugZen extends bug if($testtaskID and empty($oldBug->testtask)) $bug->testtask = $testtaskID; } - return $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->resolve['id'], $uid); + return $this->loadModel('file')->processImgURL($bug, $this->config->bug->editor->resolve['id'], $this->post->uid); } /**