diff --git a/core/displayablegraph.class.inc.php b/core/displayablegraph.class.inc.php index 94933a7f1..7ba48188c 100644 --- a/core/displayablegraph.class.inc.php +++ b/core/displayablegraph.class.inc.php @@ -702,10 +702,13 @@ class DisplayableGraph extends SimpleGraph { $oNewGraph = new DisplayableGraph(); $oNewGraph->bDirectionDown = $bDirectionDown; + $iPreviousTimeLimit = ini_get('max_execution_time'); + $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop'); $oNodesIter = new RelationTypeIterator($oGraph, 'Node'); foreach($oNodesIter as $oNode) { + set_time_limit($iLoopTimeLimit); switch(get_class($oNode)) { case 'RelationObjectNode': @@ -753,6 +756,7 @@ class DisplayableGraph extends SimpleGraph $oEdgesIter = new RelationTypeIterator($oGraph, 'Edge'); foreach($oEdgesIter as $oEdge) { + set_time_limit($iLoopTimeLimit); $oSourceNode = $oNewGraph->GetNode($oEdge->GetSourceNode()->GetId()); $oSinkNode = $oNewGraph->GetNode($oEdge->GetSinkNode()->GetId()); $oNewEdge = new DisplayableEdge($oNewGraph, $oEdge->GetId(), $oSourceNode, $oSinkNode); @@ -763,6 +767,7 @@ class DisplayableGraph extends SimpleGraph $aEdgeKeys = array(); foreach($oEdgesIter as $oEdge) { + set_time_limit($iLoopTimeLimit); $sSourceId = $oEdge->GetSourceNode()->GetId(); $sSinkId = $oEdge->GetSinkNode()->GetId(); if ($sSourceId == $sSinkId) @@ -788,6 +793,7 @@ class DisplayableGraph extends SimpleGraph $oNodesIter = new RelationTypeIterator($oNewGraph, 'Node'); foreach($oNodesIter as $oNode) { + set_time_limit($iLoopTimeLimit); if ($oNode->GetProperty('source')) { $oNode->GroupSimilarNeighbours($oNewGraph, $iGroupingThreshold, true, true); @@ -798,6 +804,7 @@ class DisplayableGraph extends SimpleGraph $iGroupIdx = 0; foreach($oIterator as $oNode) { + set_time_limit($iLoopTimeLimit); if ($oNode instanceof DisplayableGroupNode) { $aGroups[] = $oNode->GetObjects(); @@ -811,6 +818,7 @@ class DisplayableGraph extends SimpleGraph $aEdgeKeys = array(); foreach($oEdgesIter as $oEdge) { + set_time_limit($iLoopTimeLimit); $sSourceId = $oEdge->GetSourceNode()->GetId(); $sSinkId = $oEdge->GetSinkNode()->GetId(); if ($sSourceId == $sSinkId) @@ -832,7 +840,8 @@ class DisplayableGraph extends SimpleGraph } } } - + set_time_limit($iPreviousTimeLimit); + return $oNewGraph; } diff --git a/core/relationgraph.class.inc.php b/core/relationgraph.class.inc.php index b7dbddeca..e13d98867 100644 --- a/core/relationgraph.class.inc.php +++ b/core/relationgraph.class.inc.php @@ -385,6 +385,8 @@ class RelationGraph extends SimpleGraph $oObjectNode->SetProperty('developped', true); $oObject = $oObjectNode->GetProperty('object'); + $iPreviousTimeLimit = ini_get('max_execution_time'); + $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop'); foreach (MetaModel::EnumRelationQueries(get_class($oObject), $sRelCode, $bDown) as $sDummy => $aQueryInfo) { $sQuery = $bDown ? $aQueryInfo['sQueryDown'] : $aQueryInfo['sQueryUp']; @@ -403,6 +405,8 @@ class RelationGraph extends SimpleGraph { do { + set_time_limit($iLoopTimeLimit); + $sObjectRef = RelationObjectNode::MakeId($oRelatedObj); $oRelatedNode = $this->GetNode($sObjectRef); if (is_null($oRelatedNode)) @@ -426,11 +430,11 @@ class RelationGraph extends SimpleGraph } // Recurse $this->AddRelatedObjects($sRelCode, $bDown, $oRelatedNode, $iMaxDepth - 1, $bEnableRedundancy); - } while ($oRelatedObj = $oObjSet->Fetch()); } } + set_time_limit($iPreviousTimeLimit); } } } diff --git a/pages/UI.php b/pages/UI.php index 071a66381..f54480c97 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -220,11 +220,16 @@ function DisplayMultipleSelectionForm($oP, $oFilter, $sNextOperation, $oChecker, $oP->add_ready_script("$('#1 table.listResults').trigger('check_all');"); } -function DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj) +function DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj) { $oP->SetCurrentTab(Dict::S('UI:RelationshipList')); $oP->add("
"); - $oP->add("

".MetaModel::GetRelationDescription($sRelation).' '.$oObj->GetName()."

\n"); + $sOldRelation = $sRelation; + if (($sRelation == 'impacts') && ($sDirection == 'up')) + { + $sOldRelation = 'depends on'; + } + $oP->add("

".MetaModel::GetRelationDescription($sOldRelation).' '.$oObj->GetName()."

\n"); $iBlock = 1; // Zero is not a valid blockid foreach($aResults as $sListClass => $aObjects) { @@ -233,7 +238,7 @@ function DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj) $oP->add("

".MetaModel::GetClassIcon($sListClass)." ".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aObjects), Metamodel::GetName($sListClass))."

\n"); $oP->add("
\n"); $oBlock = DisplayBlock::FromObjectSet($oSet, 'list'); - $oBlock->Display($oP, $iBlock++); + $oBlock->Display($oP, $iBlock++, array('table_id' => get_class($oObj).'_'.$sRelation.'_'.$sDirection.'_'.$sListClass)); $oP->P(' '); // Some space ? } $oP->add(""); @@ -244,7 +249,7 @@ function DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj) if (count($aGroups) > 0) { $oP->SetCurrentTab(Dict::S('UI:RelationGroups')); - $oP->add("
"); + $oP->add("
"); $iBlock = 1; // Zero is not a valid blockid foreach($aGroups as $idx => $aObjects) { @@ -1518,7 +1523,7 @@ EOF // Display the tabs if ($sFirstTab == 'list') { - DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj); + DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj); $oP->SetCurrentTab(Dict::S('UI:RelationshipGraph')); $oDisplayGraph->Display($oP, $aResults, $sRelation, $oAppContext, array(), $sClassForAttachment, $iIdForAttachment, $sContextKey, array('this' => $oObj)); DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj); @@ -1527,7 +1532,7 @@ EOF { $oP->SetCurrentTab(Dict::S('UI:RelationshipGraph')); $oDisplayGraph->Display($oP, $aResults, $sRelation, $oAppContext, array(), $sClassForAttachment, $iIdForAttachment, $sContextKey, array('this' => $oObj)); - DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj); + DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj); DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj); } diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 68b678d47..659bdc32b 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -1771,6 +1771,11 @@ EOF $aSourceObjects[] = $oObj; } } + $sSourceClass = '*'; + if (count($aSourceObjects) == 1) + { + $sSourceClass = get_class($aSourceObjects[0]); + } // Get the list of excluded objects $aExcluded = utils::ReadParam('excluded', array(), false, 'raw_data'); @@ -1856,13 +1861,13 @@ EOF $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop'); foreach($aResults as $sListClass => $aObjects) { - set_time_limit($iLoopTimeLimit); + set_time_limit($iLoopTimeLimit*count($aObjects)); $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); $sHtml = "
\n"; $sHtml .= "
".MetaModel::GetClassIcon($sListClass, true, 'width: 24px; height: 24px;')." ".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', $oSet->Count(), Metamodel::GetName($sListClass))."
\n"; $sHtml .= "
\n"; $oPage->add($sHtml); - cmdbAbstractObject::DisplaySet($oPage, $oSet); + cmdbAbstractObject::DisplaySet($oPage, $oSet, array('table_id' => $sSourceClass.'_'.$sRelation.'_'.$sDirection.'_'.$sListClass)); $oPage->p(''); // Some space } @@ -1873,7 +1878,7 @@ EOF $oPage->add(''); foreach($aGroups as $idx => $aObjects) { - set_time_limit($iLoopTimeLimit); + set_time_limit($iLoopTimeLimit*count($aObjects)); $sListClass = get_class(current($aObjects)); $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); $sHtml = "
\n";