浏览代码

Prevent an exception in some (rare?) conditions where an incorrect value was set in a temporary object....cf Trac #466

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1546 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 年之前
父节点
当前提交
12235df04b
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      core/dbobject.class.php

+ 10 - 2
core/dbobject.class.php

@@ -538,8 +538,16 @@ abstract class DBObject
 		{
 		{
 			// If the object if not issued from a query but constructed programmatically
 			// If the object if not issued from a query but constructed programmatically
 			// the label may be empty. In this case run a query to get the object's friendly name
 			// the label may be empty. In this case run a query to get the object's friendly name
-			$oTmpObj = MetaModel::GetObject($sObjClass, $sObjKey);
-			$sLabel = $oTmpObj->GetName();
+			$oTmpObj = MetaModel::GetObject($sObjClass, $sObjKey, false);
+			if (is_object($oTmpObj))
+			{
+				$sLabel = $oTmpObj->GetName();
+			}
+			else
+			{
+				// May happen in case the target object is not in the list of allowed values for this attribute
+				$sLabel = "<em>$sObjClass::$sObjKey</em>";
+			}
 			//$sLabel = MetaModel::GetName($sObjClass)." #$sObjKey";
 			//$sLabel = MetaModel::GetName($sObjClass)." #$sObjKey";
 		}
 		}
 		$sHint = MetaModel::GetName($sObjClass)."::$sObjKey";
 		$sHint = MetaModel::GetName($sObjClass)."::$sObjKey";