From e45a196b7bbc0aebb0333eab58dcffeadfe970d9 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 23 Dec 2015 09:29:38 +0800 Subject: [PATCH] * fix bugs. --- module/build/model.php | 1 + module/release/control.php | 2 +- module/release/model.php | 7 +++---- module/testtask/model.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/build/model.php b/module/build/model.php index 26f076b014..7d5f90432c 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -217,6 +217,7 @@ class buildModel extends model ->where('id')->eq((int)$buildID) ->check('name', 'unique', "id != $buildID AND product = {$build->product} AND deleted = '0'") ->exec(); + if(isset($build->branch) and $oldBuild->branch != $build->branch) $this->dao->update(TABLE_RELEASE)->set('branch')->eq($build->branch)->where('build')->eq($buildID)->exec(); if(!dao::isError()) return common::createChanges($oldBuild, $build); } diff --git a/module/release/control.php b/module/release/control.php index 40e82e5d5f..5ceeeed987 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -58,7 +58,7 @@ class release extends control { if(!empty($_POST)) { - $releaseID = $this->release->create($productID); + $releaseID = $this->release->create($productID, $branch); if(dao::isError()) die(js::error(dao::getError())); $this->loadModel('action')->create('release', $releaseID, 'opened'); die(js::locate(inlink('view', "releaseID=$releaseID"), 'parent')); diff --git a/module/release/model.php b/module/release/model.php index 70ca92ec20..f799ad235c 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -100,7 +100,7 @@ class releaseModel extends model * @access public * @return int */ - public function create($productID) + public function create($productID, $branch = 0) { $buildID = 0; if($this->post->build == false) @@ -108,6 +108,7 @@ class releaseModel extends model $build = fixer::input('post') ->add('product', (int)$productID) ->add('builder', $this->app->user->account) + ->add('branch', $branch) ->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags) ->remove('build,files,labels') ->get(); @@ -116,7 +117,6 @@ class releaseModel extends model $buildID = $this->dao->lastInsertID(); } - $branch = 0; if($this->post->build) $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch'); $release = fixer::input('post') ->add('product', (int)$productID) @@ -152,8 +152,7 @@ class releaseModel extends model public function update($releaseID) { $oldRelease = $this->getByID($releaseID); - - $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch'); + $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch'); $release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags) ->add('branch', (int)$branch) diff --git a/module/testtask/model.php b/module/testtask/model.php index 9087a83f28..38a32eccfd 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -326,7 +326,7 @@ class testtaskModel extends model * */ $postData = fixer::input('post')->get(); $caseResult = isset($postData->result) ? $postData->result : 'pass'; - if($postData->steps) + if(isset($postData->steps) and $postData->steps) { foreach($postData->steps as $stepID => $stepResult) { @@ -339,7 +339,7 @@ class testtaskModel extends model } /* Create result of every step. */ - if($postData->steps) + if(isset($postData->steps) and $postData->steps) { foreach($postData->steps as $stepID =>$stepResult) {