From 641c13383b11d107bb9f0573a6ed92151d1a910d Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 16 Jun 2022 16:06:55 +0800 Subject: [PATCH] * Fix bug #23855. --- db/update17.0.sql | 2 ++ module/program/model.php | 11 +++++------ module/upgrade/model.php | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/db/update17.0.sql b/db/update17.0.sql index 832ca723af..86f5ebecbb 100644 --- a/db/update17.0.sql +++ b/db/update17.0.sql @@ -11,3 +11,5 @@ DELETE FROM `zt_workflowaction` WHERE `module`='task' AND `action`='browse'; DELETE FROM `zt_workflowaction` WHERE `module`='build' AND `action`='browse'; ALTER TABLE `zt_projectproduct` MODIFY COLUMN `plan` varchar(255) NOT NULL; + +UPDATE `zt_project` SET `grade`=1 WHERE `type` in ('project', 'sprint', 'kanban'); diff --git a/module/program/model.php b/module/program/model.php index 79f515a768..85f6639aee 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1335,17 +1335,16 @@ class programModel extends model /* Process child node path and grade field. */ foreach($childNodes as $childNode) { - $path = substr($childNode->path, strpos($childNode->path, ",{$programID},")); - $grade = $childNode->grade - $oldGrade + 1; + $path = substr($childNode->path, strpos($childNode->path, ",{$programID},")); + + /* Only program sets update grade. */ + $grade = $childNode->type == 'program' ? $childNode->grade - $oldGrade + 1 : $childNode->grade; if($parent) { $path = rtrim($parent->path, ',') . $path; - $grade = $parent->grade + $grade; + $grade = $childNode->type == 'program' ? $parent->grade + $grade : $grade; } - /* Only program sets update grade. */ - if($childNode->type != 'program') $grade = $childNode->grade; - $this->dao->update(TABLE_PROGRAM)->set('path')->eq($path)->set('grade')->eq($grade)->where('id')->eq($childNode->id)->exec(); } diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 73e2edea46..abf768c9aa 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -513,6 +513,7 @@ class upgradeModel extends model break; case '17_0': $this->replaceSetLanePriv(); + $this->updateGradeOfStage(); break; } @@ -6358,4 +6359,26 @@ class upgradeModel extends model return true; } + + /** + * Update grade of stage. + * + * @access public + * @return void + */ + public function updateGradeOfStage() + { + $allStages = $this->dao->select('*')->from(TABLE_EXECUTION)->where('type')->eq('stage')->fetchAll('id'); + $updateIDList = array(); + foreach($allStages as $stageID => $stage) + { + if($stage->project != $stage->parent) $updateIDList[$stageID] = $stageID; + } + + if(!empty($updateIDList)) + { + $this->dao->update(TABLE_EXECUTION)->set('grade')->eq(2)->where('type')->eq('stage')->andWhere('id')->in($updateIDList)->exec(); + } + return true; + } }