浏览代码

Fixed an incorrect detection of the maximum recursion level

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1079 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 年之前
父节点
当前提交
58ab69d981
共有 1 个文件被更改,包括 3 次插入5 次删除
  1. 3 5
      pages/xml.navigator.php

+ 3 - 5
pages/xml.navigator.php

@@ -59,12 +59,10 @@ function AddNodeDetails(&$oNode, $oObj)
  * @param DBObject $oObj The current object
  * @param string $sRelation The name of the relation to search with
  */
-function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode)
+function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode, $iDepth = 0)
 {
 	$aResults = array();
 	$oObj->GetRelatedObjects($sRelationName, 1 /* iMaxDepth */, $aResults);
-	static $iDepth = 0;
-	$iDepth++;
 	if ($iDepth > MAX_RECURSION_DEPTH) return;
 	
 	foreach($aResults as $sRelatedClass => $aObjects)
@@ -85,7 +83,7 @@ function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXml
 				AddNodeDetails($oLinkedNode, $oTargetObj);
 				$oSubLinks = $oXmlDoc->CreateElement('links');
 				// Recurse
-				GetRelatedObjectsAsXml($oTargetObj, $sRelationName, $oSubLinks, $oXmlDoc, $oLinkedNode);
+				GetRelatedObjectsAsXml($oTargetObj, $sRelationName, $oSubLinks, $oXmlDoc, $oLinkedNode, $iDepth++);
 				$oLinkingNode->AppendChild($oLinkedNode);
 				$oLinks->AppendChild($oLinkingNode);
 			}
@@ -185,4 +183,4 @@ catch(Exception $e)
 {
 	echo "Error: ".$e->getMessage();
 }
-?>
+?>