From 3989c71b3fe2418ed644476e9ddbc57ed72c6b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Fri, 15 Oct 2021 13:38:05 +0800 Subject: [PATCH] * fix for large size session. --- module/common/model.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 11ca093df1..210de9d9fa 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1683,10 +1683,10 @@ EOD; { $key = (!$this->session->$typeOnlyCondition and $type == 'testcase' and isset($object->case)) ? 'case' : 'id'; $id = $object->$key; - $objectList[$id] = $object; + $objectList[$id] = $id; } - $this->session->set($objectIdListKey, array('sql' => $sql, 'objectList' => $objectList), $this->app->tab); + $this->session->set($objectIdListKey, array('idkey' => $key, 'objectList' => $objectList), $this->app->tab); $existsObjectList = $this->session->$objectIdListKey; } @@ -1697,12 +1697,12 @@ EOD; $preObj = false; if(isset($existsObjectList['objectList'])) { - foreach($existsObjectList['objectList'] as $id => $object) + foreach($existsObjectList['objectList'] as $id) { /* Get next object. */ if($preObj === true) { - $preAndNextObject->next = $object; + $preAndNextObject->next = $id; break; } @@ -1712,7 +1712,20 @@ EOD; if($preObj) $preAndNextObject->pre = $preObj; $preObj = true; } - if($preObj !== true) $preObj = $object; + if($preObj !== true) $preObj = $id; + } + + if(empty($queryCondition) or $this->session->$typeOnlyCondition) + { + if(!empty($preAndNextObject->pre)) $preAndNextObject->pre = $this->dao->select('*')->from($table)->where('id')->eq($preAndNextObject->pre)->fetch(); + if(!empty($preAndNextObject->next)) $preAndNextObject->next = $this->dao->select('*')->from($table)->where('id')->eq($preAndNextObject->next)->fetch(); + } + else + { + $key = $existsObjectList['idkey']; + $hasWhere = srtipos($queryCondition, ' where ') !== false; + if(!empty($preAndNextObject->pre)) $preAndNextObject->pre = $this->dao->query($queryCondition . ($hasWhere ? " AND `$key`='{$preAndNextObject->pre}' " : " WHERE `$key`='{$preAndNextObject->pre}' "))->fetch(); + if(!empty($preAndNextObject->next)) $preAndNextObject->next = $this->dao->query($queryCondition . ($hasWhere ? " AND `$key`='{$preAndNextObject->next}' " : " WHERE `$key`='{$preAndNextObject->next}' "))->fetch(); } }