mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Merged-in bug fixes from the main trunk: recursion issue and assertion failed message.
SVN:1.0.2[1081]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -139,7 +137,7 @@ try
|
||||
$aResults = array();
|
||||
$oObj->GetRelatedObjects($sRelation, MAX_RECURSION_DEPTH /* iMaxDepth */, $aResults);
|
||||
|
||||
$iBlock = 0;
|
||||
$iBlock = 1; // Zero is not a valid blockid
|
||||
foreach($aResults as $sClass => $aObjects)
|
||||
{
|
||||
$oSet = CMDBObjectSet::FromArray($sClass, $aObjects);
|
||||
@@ -185,4 +183,4 @@ catch(Exception $e)
|
||||
{
|
||||
echo "Error: ".$e->getMessage();
|
||||
}
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user