From 077b7be2a4ed8c481679baeba3a9fead0bb1f98b Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Tue, 28 Jun 2011 09:32:13 +0000 Subject: [PATCH] Fixed regressions with DBObjectSet, impacting the new paginated lists and their menus SVN:trunk[1302] --- core/dbobjectset.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index 654f397f3..c7567608c 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -32,7 +32,7 @@ class DBObjectSet { private $m_oFilter; - private $m_aAddedIds; // Ids of objects added + private $m_aAddedIds; // Ids of objects added (discrete lists) private $m_aOrderBy; public $m_bLoaded; private $m_aData; @@ -275,8 +275,9 @@ class DBObjectSet } else { - $oFilter = $this->m_oFilter; - $oIdListExpr = ListExpression::FromScalars($this->m_aAddedIds); + $oFilter = clone $this->m_oFilter; + + $oIdListExpr = ListExpression::FromScalars(array_keys($this->m_aAddedIds)); $oIdExpr = new FieldExpression('id', $oFilter->GetClassAlias()); $oIdInList = new BinaryExpression($oIdExpr, 'IN', $oIdListExpr); $oFilter->MergeConditionExpression($oIdInList); @@ -351,9 +352,10 @@ class DBObjectSet { $oObject = MetaModel::GetObjectByRow($sClass, $aRow, $sClassAlias, $this->m_aAttToLoad, $this->m_aExtendedDataSpec); } + $aObjects[$sClassAlias] = $oObject; } - $this->AddObjectExtended($aObjects); + $this->AddObjectExtended($aObjects, true /* internal load */); } CMDBSource::FreeResult($resQuery); } @@ -444,11 +446,11 @@ class DBObjectSet if (!is_null($oObject)) { $this->m_aId2Row[$sClassAlias][$oObject->GetKey()] = $iNextPos; - $this->m_aAddedIds[] = $oObject->GetKey(); + $this->m_aAddedIds[$oObject->GetKey()] = true; } } - protected function AddObjectExtended($aObjectArray) + protected function AddObjectExtended($aObjectArray, $bInternalLoad = false) { if (!$this->m_bLoaded) $this->Load(); @@ -460,7 +462,10 @@ class DBObjectSet if (!is_null($oObject)) { $this->m_aId2Row[$sClassAlias][$oObject->GetKey()] = $iNextPos; - $this->m_aAddedIds[] = $oObject->GetKey(); + if (!$bInternalLoad) + { + $this->m_aAddedIds[$oObject->GetKey()] = true; + } } } }