From 89328e1662df54d497e1f5d4d5e2d3a9511be0ed Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 10 May 2016 15:33:48 +0000 Subject: [PATCH] Prevent infinite cross-ticket recursion when propagating parent->child resolution in tickets. SVN:trunk[4045] --- .../datamodel.itop-incident-mgmt-itil.xml | 29 +++++++++++++------ .../datamodel.itop-request-mgmt-itil.xml | 8 ++++- .../datamodel.itop-request-mgmt.xml | 8 ++++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml index 6e8448c0ab..449c572282 100755 --- a/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml +++ b/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml @@ -1164,15 +1164,22 @@ $this->GetKey())); - while($oRequest = $oChildRequestSet->Fetch()) - { - $oRequest->ResolveFrom($this); - } + { + // Automatically resolve child requests + $sOQL = "SELECT UserRequest WHERE parent_incident_id = :ticket AND status != 'resolved'"; + $oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('ticket' => $this->GetKey())); + while($oRequest = $oChildRequestSet->Fetch()) + { + if (!array_key_exists($oRequest->GetKey(), $aRequests)) + { + $aRequests[$oRequest->GetKey()] = true; + $oRequest->ResolveFrom($this); + } + } } // Automatically resolve child incidents @@ -1180,7 +1187,11 @@ $oChildIncidentSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('ticket' => $this->GetKey())); while($oIncident = $oChildIncidentSet->Fetch()) { - $oIncident->ResolveFrom($this); + if (!array_key_exists($oIncident->GetKey(), $Incidents)) + { + $Incidents[$oIncident->GetKey()] = true; + $oIncident->ResolveFrom($this); + } } return true; }]]> diff --git a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml index 6fb81e76d3..fd93b32823 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml +++ b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml @@ -1278,12 +1278,18 @@ $this->GetKey())); while($oRequest = $oChildRequestSet->Fetch()) { - $oRequest->ResolveFrom($this); + if (!array_key_exists($oRequest->GetKey(), $aTickets)) + { + $aTickets[$oRequest->GetKey()] = true; + $oRequest->ResolveFrom($this); + } } return true; }]]> diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml index 76aa59c32d..a8ac8438f1 100755 --- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml +++ b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml @@ -1280,12 +1280,18 @@ $this->GetKey())); while($oRequest = $oChildRequestSet->Fetch()) { - $oRequest->ResolveFrom($this); + if (!array_key_exists($oRequest->GetKey(), $aTickets)) + { + $aTickets[$oRequest->GetKey()] = true; + $oRequest->ResolveFrom($this); + } } return true; }]]>