From dd1cf43d4103af7c191bda3df931cf03c2de3c56 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Mon, 25 Nov 2013 15:10:09 +0000 Subject: [PATCH] #830 Regression introduced in the beta. Related to the management of query arguments SVN:trunk[2980] --- core/dbobjectset.class.php | 10 ++-------- core/expression.class.inc.php | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php index fe7336e95..b363541ad 100644 --- a/core/dbobjectset.class.php +++ b/core/dbobjectset.class.php @@ -738,14 +738,8 @@ class DBObjectSet { foreach($aVals as $sCode => $oExpr) { - if ($oExpr instanceof ScalarExpression) - { - $aConst[$sClassAlias][$sCode] = $oExpr->GetValue(); - } - else //Variable - { - $aConst[$sClassAlias][$sCode] = $aScalarArgs[$oExpr->GetName()]; - } + $oScalarExpr = $oExpr->GetAsScalar($aScalarArgs); + $aConst[$sClassAlias][$sCode] = $oScalarExpr->GetValue(); } } return $aConst; diff --git a/core/expression.class.inc.php b/core/expression.class.inc.php index 6450b6373..784376961 100644 --- a/core/expression.class.inc.php +++ b/core/expression.class.inc.php @@ -647,12 +647,29 @@ class VariableExpression extends UnaryExpression public function GetAsScalar($aArgs) { - $value = ''; + $value = null; if (array_key_exists($this->m_sName, $aArgs)) { $value = $aArgs[$this->m_sName]; } - else + elseif (($iPos = strpos($this->m_sName, '->')) !== false) + { + $sParamName = substr($this->m_sName, 0, $iPos); + if (array_key_exists($sParamName.'->object()', $aArgs)) + { + $sAttCode = substr($this->m_sName, $iPos + 2); + $oObj = $aArgs[$sParamName.'->object()']; + if ($sAttCode == 'id') + { + $value = $oObj->GetKey(); + } + else + { + $value = $oObj->Get($sAttCode); + } + } + } + if (is_null($value)) { throw new MissingQueryArgument('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>array_keys($aArgs))); }