diff --git a/module/action/model.php b/module/action/model.php index c5534540a7..9a1cad8dfe 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -80,10 +80,8 @@ class actionModel extends model $this->dao->insert(TABLE_ACTION)->data($action)->autoCheck()->exec(); $actionID = $this->dao->lastInsertID(); - $productIdList = array_filter(explode(',', $action->product)); - foreach($productIdList as $productID) $this->dao->insert(TABLE_ACTIONPRODUCT)->set('action')->eq($actionID)->set('product')->eq($productID)->exec(); - - $hasRecentTable = true; + $hasProductTable = true; + $hasRecentTable = true; if($this->app->upgrading) { $fromVersion = $this->loadModel('setting')->getItem('owner=system&module=common§ion=global&key=version'); @@ -92,6 +90,18 @@ class actionModel extends model if(strpos($fromVersion, 'biz') !== false && version_compare($fromVersion, 'biz8.6', '<')) $hasRecentTable = false; if(strpos($fromVersion, 'max') !== false && version_compare($fromVersion, 'max4.6', '<')) $hasRecentTable = false; if(strpos($fromVersion, 'ipd') !== false && version_compare($fromVersion, 'ipd1.0.1', '<')) $hasRecentTable = false; + + if(is_numeric($fromVersion[0]) && version_compare($fromVersion, '21.7.1', '<=')) $hasProductTable = false; + if(strpos($fromVersion, 'pro') !== false) $hasProductTable = false; + if(strpos($fromVersion, 'biz') !== false && version_compare($fromVersion, 'biz12.0', '<=')) $hasProductTable = false; + if(strpos($fromVersion, 'max') !== false && version_compare($fromVersion, 'max7.0', '<=')) $hasProductTable = false; + if(strpos($fromVersion, 'ipd') !== false && version_compare($fromVersion, 'ipd4.0', '<=')) $hasProductTable = false; + } + + if($hasProductTable) + { + $productIdList = array_filter(explode(',', $action->product)); + foreach($productIdList as $productID) $this->dao->insert(TABLE_ACTIONPRODUCT)->set('action')->eq($actionID)->set('product')->eq($productID)->exec(); } if($actionType == 'commented') diff --git a/module/action/test/lib/action.unittest.class.php b/module/action/test/lib/action.unittest.class.php index c5ee9bb300..b54ed5d7a0 100644 --- a/module/action/test/lib/action.unittest.class.php +++ b/module/action/test/lib/action.unittest.class.php @@ -28,14 +28,7 @@ class actionTest global $tester, $config; if($tester->app->upgrading && !empty($version)) { - global $tester; - $data = new stdclass(); - $data->value = $version; - $data->key = 'version'; - $data->owner = 'system'; - $data->module = 'common'; - $data->section = 'global'; - $tester->dao->replace(TABLE_CONFIG)->data($data)->exec(); + $tester->dao->update(TABLE_CONFIG)->set('value')->eq($version)->where('`key`')->eq('version')->andWhere('owner')->eq('system')->andWhere('module')->eq('common')->andWhere('section')->eq('global')->exec(); } $_SERVER['HTTP_HOST'] = 'pms.zentao.com'; diff --git a/module/action/test/model/create.php b/module/action/test/model/create.php index 3e880ee57b..0fd7cf9c12 100755 --- a/module/action/test/model/create.php +++ b/module/action/test/model/create.php @@ -3,8 +3,9 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; include dirname(__FILE__, 2) . '/lib/action.unittest.class.php'; -zenData('actionrecent')->gen(0); zenData('action')->gen(0); +zenData('actionrecent')->gen(0); +zenData('actionproduct')->gen(0); zenData('file')->gen(0); zenData('task')->gen(1); zenData('story')->gen(1); @@ -54,8 +55,10 @@ cid=1 - 属性objectID @1 - 属性actor @系统 - 属性action @synctwins -- 测试升级中的并且版本号小于18.7的情况,不创建actionrecent @8 +- 测试升级中的并且版本号小于18.7的情况,不创建actionrecent @7 +- 测试升级中的并且版本号小于21.7.2的情况,不创建actionproduct @7 - 测试升级中的并且版本号大于18.7的情况,创建actionrecent @8 +- 测试升级中的并且版本号小于21.7.2的情况,创建actionproduct @8 */ $objectTypeList = array('task', 'project', 'user', 'bug', 'story'); @@ -66,7 +69,7 @@ $actor = 'guest'; $comment = array('', '测试备注', '