浏览代码

#830 Regression introduced in the beta. Related to the management of query arguments

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2980 a333f486-631f-4898-b8df-5754b55c2be0
romainq 11 年之前
父节点
当前提交
ff24625bd5
共有 2 个文件被更改,包括 21 次插入10 次删除
  1. 2 8
      core/dbobjectset.class.php
  2. 19 2
      core/expression.class.inc.php

+ 2 - 8
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;		

+ 19 - 2
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)));
 		}