From e260ad29a0a41a60f165470ec8105f11418e3143 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Tue, 7 Feb 2023 14:43:20 +0800 Subject: [PATCH] * Code for bug#31948. --- module/project/control.php | 20 +++++++++++++------- module/project/model.php | 6 ++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/module/project/control.php b/module/project/control.php index eb1771c9bc..85f6409c8b 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -2171,7 +2171,8 @@ class project extends control $this->loadModel('program'); $this->loadModel('execution'); - $project = $this->project->getById($projectID); + $project = $this->project->getById($projectID); + $executions = $this->execution->getPairs($projectID); if(!empty($_POST)) { @@ -2182,11 +2183,7 @@ class project extends control } $oldProducts = $this->product->getProducts($projectID); - if($project->multiple and $project->model != 'waterfall') - { - $executions = $this->dao->select('id')->from(TABLE_EXECUTION)->where('project')->eq($projectID)->fetchPairs('id'); - $oldExecutionProducts = $this->dao->select('project,product')->from(TABLE_PROJECTPRODUCT)->where('project')->in($executions)->fetchGroup('project', 'product'); - } + if($project->multiple and $project->model != 'waterfall') $oldExecutionProducts = $this->dao->select('project,product')->from(TABLE_PROJECTPRODUCT)->where('project')->in(array_keys($executions))->fetchGroup('project', 'product'); $this->project->updateProducts($projectID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -2203,6 +2200,15 @@ class project extends control $diffProducts = array_merge(array_diff($oldProductIDs, $newProductIDs), array_diff($newProductIDs, $oldProductIDs)); if($diffProducts) $this->loadModel('action')->create('project', $projectID, 'Managed', '', !empty($_POST['products']) ? join(',', $_POST['products']) : ''); + if(empty($project->division)) + { + foreach(array_keys($executions) as $executionID) + { + $this->execution->updateProducts($executionID); + if($diffProducts) $this->loadModel('action')->create('execution', $executionID, 'Managed', '', implode(',', array_keys($newProducts))); + } + } + if($project->multiple and $project->model != 'waterfall') { $unlinkedProducts = array_diff($oldProductIDs, $newProductIDs); @@ -2317,7 +2323,7 @@ class project extends control $this->view->unmodifiableBranches = $unmodifiableBranches; $this->view->unmodifiableMainBranches = $unmodifiableMainBranches; $this->view->branchGroups = $branchGroups; - $this->view->executions = $this->execution->getPairs($projectID); + $this->view->executions = $executions; $this->view->allBranches = $this->branch->getByProducts(array_keys($allProducts), 'ignoreNormal'); $this->view->allProducts = $allProducts; diff --git a/module/project/model.php b/module/project/model.php index be500760cc..94f06a2041 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1634,6 +1634,12 @@ class projectModel extends model if(!dao::isError()) { $this->updateProducts($projectID, $_POST['products']); + if(empty($oldProject->division)) + { + $executions = $this->loadModel('execution')->getPairs($projectID); + foreach(array_keys($executions) as $executionID) $this->execution->updateProducts($executionID); + } + $this->file->updateObjectID($this->post->uid, $projectID, 'project'); $whitelist = explode(',', $project->whitelist);