From 96d2f5a07d48491a92d3ee80452bec9df1ba9086 Mon Sep 17 00:00:00 2001 From: Guanxiying Date: Wed, 28 Apr 2021 09:56:44 +0800 Subject: [PATCH 01/10] * Fix comments of public funtions. --- test/init.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/init.php b/test/init.php index 7fbea75295..93c3aa8626 100644 --- a/test/init.php +++ b/test/init.php @@ -29,6 +29,13 @@ $tester = $app->loadCommon(); $config->zendataRoot = dirname(__FILE__) . DS . 'zendata'; $config->zdPath = "/usr/local/zd/zd"; +/** + * Save variable to $_result. + * + * @param mix $result + * @access public + * @return bool true + */ function run($result) { global $_result; @@ -36,6 +43,14 @@ function run($result) return true; } +/** + * Print expect data. + * + * @param int $key + * @param string $delimiter + * @access public + * @return void + */ function expect($key, $delimiter = ',') { global $_result; @@ -66,6 +81,15 @@ function expect($key, $delimiter = ',') echo "\n"; } +/** + * Import data create by zendata to one table. + * + * @param string $table + * @param string $yaml + * @param int $count + * @access public + * @return void + */ function zdImport($table, $yaml, $count = 10) { chdir(dirname(__FILE__)); From 3b8dd3db340ccc4a56d028a4f7b0e1a8f1f7f0c3 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 28 Apr 2021 10:53:52 +0800 Subject: [PATCH 02/10] * fix bug #12050. --- lib/scm/gitlab.class.php | 11 +++++++++-- module/repo/control.php | 2 +- module/repo/model.php | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php index ecf9871531..aad2bbb639 100644 --- a/lib/scm/gitlab.class.php +++ b/lib/scm/gitlab.class.php @@ -501,7 +501,8 @@ class gitlab if($version) { $lastCommit = $this->getSingleCommit($version); - if(empty($lastCommit)) return array(); + if(!isset($lastCommit->committed_date)) return array('commits' => array(), 'files' => array()); + $params['until'] = $lastCommit->committed_date; } @@ -644,7 +645,13 @@ class gitlab $api = ltrim($api, '/'); $api = $this->root . $api . '?' . http_build_query($params); - $response = file_get_contents($api); + $response = commonModel::http($api); + if(!empty(commonModel::$requestErrors)) + { + commonModel::$requestErrors = array(); + return array(); + } + return json_decode($response); } diff --git a/module/repo/control.php b/module/repo/control.php index 9580fd9d4f..411c1b0bc5 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -867,7 +867,7 @@ class repo extends control set_time_limit(0); $repo = $this->repo->getRepoByID($repoID); if(empty($repo)) die(); - //if($repo->synced) die('finish'); + if($repo->synced) die('finish'); $this->commonAction($repoID); $this->scm->setEngine($repo); diff --git a/module/repo/model.php b/module/repo/model.php index fd22ec2338..03ec69715a 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -281,15 +281,18 @@ class repoModel extends model $repo = $this->getRepoByID($id); $data = fixer::input('post') + ->setIf($this->post->SCM == 'Gitlab', 'password', $this->post->gitlabToken) + ->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost) + ->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject) ->setDefault('client', 'svn') ->setDefault('prefix', $repo->prefix) ->setDefault('product', '') - ->setIF($this->post->path != $repo->path, 'synced', 0) ->skipSpecial('path,client,account,password') ->join('product', ',') ->get(); if($this->post->SCM == 'Gitlab') $data->path = sprintf($this->config->repo->gitlab->apiPath, $data->gitlabHost, $this->post->gitlabProject); + if($data->path != $repo->path) $data->synced = 0; $data->acl = empty($data->acl) ? '' : json_encode($data->acl); @@ -313,7 +316,7 @@ class repoModel extends model $this->dao->update(TABLE_REPO)->data($data, $skip = 'gitlabHost,gitlabToken,gitlabProject') ->batchCheck($this->config->repo->edit->requiredFields, 'notempty') ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') - ->checkIF($data->SCM == 'GitLab', 'gitlabProject', 'notempty') + ->checkIF($data->SCM == 'GitLab', 'extra', 'notempty') ->autoCheck() ->where('id')->eq($id)->exec(); From 09acfbbc531dc7a10f661944033155d29d8e9757 Mon Sep 17 00:00:00 2001 From: hufangzhou <746775970@qq.com> Date: Wed, 28 Apr 2021 11:00:28 +0800 Subject: [PATCH 03/10] * Modify the project doc lib acl when the project acl is program. --- module/project/model.php | 2 +- module/upgrade/model.php | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index a078124118..3b5b3a0d57 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -748,7 +748,7 @@ class projectModel extends model $lib->name = $this->lang->doclib->main['project']; $lib->type = 'project'; $lib->main = '1'; - $lib->acl = $project->acl; + $lib->acl = $project->acl != 'program' ? $project->acl : 'custom'; $this->dao->insert(TABLE_DOCLIB)->data($lib)->exec(); $this->updateProducts($projectID); diff --git a/module/upgrade/model.php b/module/upgrade/model.php index c02e3b4791..cefc175566 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -647,6 +647,10 @@ class upgradeModel extends model $this->saveLogs('Execute 15_0_rc2'); $this->execSQL($this->getUpgradeFile('15.0.rc2')); $this->appendExec('15_0_rc2'); + case '15_0_rc3': + $this->saveLogs('Execute 15_0_rc3'); + $this->updateLibType(); + $this->appendExec('15_0_rc3'); } $this->deletePatch(); @@ -4304,7 +4308,7 @@ class upgradeModel extends model $lib->name = $this->lang->doclib->main['project']; $lib->type = 'project'; $lib->main = '1'; - $lib->acl = $project->acl; + $lib->acl = $project->acl != 'program' ? $project->acl : 'custom'; $this->dao->insert(TABLE_DOCLIB)->data($lib)->exec(); $this->loadModel('action')->create('project', $projectID, 'openedbysystem'); @@ -4863,4 +4867,18 @@ class upgradeModel extends model return true; } + + /** + * Update execution main doclib type. + * + * @access public + * @return bool + */ + public function updateLibType() + { + $executionList = $this->dao->select('id')->from(TABLE_EXECUTION)->where('type')->eq('sprint')->fetchAll('id'); + $this->dao->update(TABLE_DOCLIB)->set('type')->eq('execution')->where('execution')->in(array_keys($executionList))->exec(); + + return true; + } } From c201e15bb4822211f253752206ebab2abd66ac73 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 28 Apr 2021 11:09:03 +0800 Subject: [PATCH 04/10] * fix bug. --- module/bug/control.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index aa08869665..9bf56305b2 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -546,7 +546,7 @@ class bug extends control } /* Get executions. */ - $executions = array('' => ''); + $executions = array(0 => ''); if(isset($projects[$projectID]) or $this->config->systemMode == 'classic') $executions += $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, 'id_desc', $projectID); /* Set custom. */ @@ -877,7 +877,7 @@ class bug extends control $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $bug->branch); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); $this->view->currentModuleID = $currentModuleID; - $this->view->executions = $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $projectID); + $this->view->executions = array(0 => '') + $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'id_desc', $projectID); $this->view->stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch); $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product); $this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution); From 3ec725bfa688b4c8be2a61f5007422781d5f88f2 Mon Sep 17 00:00:00 2001 From: Guanxiying Date: Wed, 28 Apr 2021 11:39:46 +0800 Subject: [PATCH 05/10] * Fix spelling mistakes. --- test/init.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/init.php b/test/init.php index 93c3aa8626..5b362be7c9 100644 --- a/test/init.php +++ b/test/init.php @@ -46,8 +46,8 @@ function run($result) /** * Print expect data. * - * @param int $key - * @param string $delimiter + * @param string $key + * @param string $delimiter * @access public * @return void */ @@ -96,6 +96,6 @@ function zdImport($table, $yaml, $count = 10) global $app, $config; $dns = "mysql://{$config->db->user}:{$config->db->password}@{$config->db->host}:{$config->db->port}/{$config->db->name}#utf8"; $table = trim($table, '`'); - $commad = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count"; - system($commad); + $command = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count"; + system($command); } From 962685950e4ccd356c5efdfdd362301fcc431bc5 Mon Sep 17 00:00:00 2001 From: Guanxiying Date: Wed, 28 Apr 2021 11:41:02 +0800 Subject: [PATCH 06/10] * Add field param to comments of getById function. --- module/user/model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/user/model.php b/module/user/model.php index 3b68f42bee..b21d70430b 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -192,6 +192,7 @@ class userModel extends model * Get user info by ID. * * @param mix $userID + * @param string $field id|account * @access public * @return object|bool */ From 2e03100a96f5a6f9499d82044a847dff6875a474 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 28 Apr 2021 13:12:21 +0800 Subject: [PATCH 07/10] * Fix bug. --- module/upgrade/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/upgrade/control.php b/module/upgrade/control.php index 403469e06c..f51da2b2be 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -134,7 +134,7 @@ class upgrade extends control if(!$this->upgrade->isError()) { - if(!$this->config->systemMode && !isset($this->config->qcVersion)) $this->locate(inlink('to15Guide', "fromVersion=$fromVersion")); + if(!$this->config->systemMode && !isset($this->config->qcVersion) && strpos($fromVersion, 'max') === false) $this->locate(inlink('to15Guide', "fromVersion=$fromVersion")); $this->locate(inlink('afterExec', "fromVersion=$fromVersion")); } From 375b47bf8300542dd7586ce0bea40c2698032b81 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Wed, 28 Apr 2021 13:12:56 +0800 Subject: [PATCH 08/10] * wrap get file size. --- module/file/control.php | 2 +- module/file/model.php | 31 +++++++++++++++++++++++++--- module/file/view/printfiles.html.php | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/module/file/control.php b/module/file/control.php index e9c08f9a49..ff5e46caa4 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -63,7 +63,7 @@ class file extends control die(json_encode(array('error' => 1, 'message' => $this->lang->file->errorFileUpload))); } } - if(@helper::saveFile($file['tmpname'], $this->file->savePath . $this->file->getSaveName($file['pathname']))) + if(@move_uploaded_file($file['tmpname'], $this->file->savePath . $this->file->getSaveName($file['pathname']))) { /* Compress image for jpg and bmp. */ $file = $this->file->compressImage($file); diff --git a/module/file/model.php b/module/file/model.php index c798587d83..1a2252c579 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -262,7 +262,7 @@ class fileModel extends model } else { - if(!helper::saveFile($file['tmpname'], $tmpFileChunkPath)) return false; + if(!move_uploaded_file($file['tmpname'], $tmpFileChunkPath)) return false; } if($file['chunk'] == ($file['chunks'] - 1)) @@ -278,7 +278,7 @@ class fileModel extends model } else { - if(!helper::saveFile($file['tmpname'], $file['realpath'])) return false; + if(!move_uploaded_file($file['tmpname'], $file['realpath'])) return false; $uploadFile['extension'] = $file['extension']; $uploadFile['pathname'] = $file['pathname']; @@ -471,7 +471,7 @@ class fileModel extends model $pathName = $filePath->pathname; $realPathName = $this->savePath . $this->getRealPathName($pathName); if(!is_dir(dirname($realPathName))) mkdir(dirname($realPathName)); - helper::saveFile($file['tmpname'], $realPathName); + move_uploaded_file($file['tmpname'], $realPathName); $file['pathname'] = $pathName; $file = $this->compressImage($file); @@ -966,4 +966,29 @@ class fileModel extends model die(); } } + + /** + * Get image size. + * + * @access public + * @param object $file + * @return array + */ + public function getImageSize($file) + { + if($this->config->file->storageType == 'fs') + { + return getimagesize($file->realPath); + } + else if($this->config->file->storageType == 's3') + { + $this->app->loadClass('ossclient', true); + + $config = $this->config->file; + $ossClient = new ossclient($config->accessKeyId, $config->accessKeySecret, $config->endpoint, $config->bucket); + $info = $ossClient->getImageInfo($file->pathname); + + return array($info->ImageWidth->value, $info->ImageHeight->value, 'img'); + } + } } diff --git a/module/file/view/printfiles.html.php b/module/file/view/printfiles.html.php index b7de5a98cf..e4c7c2a783 100644 --- a/module/file/view/printfiles.html.php +++ b/module/file/view/printfiles.html.php @@ -53,7 +53,7 @@ $sessionString .= session_name() . '=' . session_id(); $imageWidth = 0; if(stripos('jpg|jpeg|gif|png|bmp', $file->extension) !== false) { - $imageSize = getimagesize($file->realPath); + $imageSize = $this->file->getImageSize($file); $imageWidth = $imageSize ? $imageSize[0] : 0; } From 88e140be8fad845789981f813ba5ac5dd7bfea05 Mon Sep 17 00:00:00 2001 From: hufangzhou <746775970@qq.com> Date: Wed, 28 Apr 2021 14:27:41 +0800 Subject: [PATCH 09/10] * Update the user view when create project. --- module/project/model.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/module/project/model.php b/module/project/model.php index 3b5b3a0d57..66cfcf19ab 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -815,6 +815,8 @@ class projectModel extends model $this->dao->replace(TABLE_USERGROUP)->data($groupPriv)->exec(); } + $this->loadModel('user')->updateUserView($projectID, 'project'); + return $projectID; } } From bbf9941348ded84a609634b36b3b9ea5a2fb3df5 Mon Sep 17 00:00:00 2001 From: hufangzhou <746775970@qq.com> Date: Wed, 28 Apr 2021 14:29:53 +0800 Subject: [PATCH 10/10] * Adjust the code. --- module/project/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/project/model.php b/module/project/model.php index 66cfcf19ab..2c27689277 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -815,7 +815,7 @@ class projectModel extends model $this->dao->replace(TABLE_USERGROUP)->data($groupPriv)->exec(); } - $this->loadModel('user')->updateUserView($projectID, 'project'); + if($project->acl != 'open') $this->loadModel('user')->updateUserView($projectID, 'project'); return $projectID; }