From ea686059b65dd6ee73ea7c3aac53c82829ba3024 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 3 Jul 2013 09:47:44 +0000 Subject: [PATCH] Protect against non existing reconciliation keys... SVN:trunk[2788] --- setup/modelfactory.class.inc.php | 45 +++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index e6814a428..b34f9e7eb 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -1557,31 +1557,34 @@ class MFElement extends DOMElement $aRanks = array(); foreach($oItems->childNodes as $oItem) { - // When an attribute is missing - if ($oItem->hasAttribute('id')) + if ($oItem instanceof DOMElement) { - $key = $oItem->getAttribute('id'); - if (array_key_exists($key, $res)) + // When an attribute is missing + if ($oItem->hasAttribute('id')) { - // Houston! - throw new DOMFormatException("Tag ".$oItem->getNodePath().", id '$key' already used!!!"); + $key = $oItem->getAttribute('id'); + if (array_key_exists($key, $res)) + { + // Houston! + throw new DOMFormatException("Tag ".$oItem->getNodePath().", id '$key' already used!!!"); + } + $res[$key] = $oItem->GetNodeAsArrayOfItems(); } - $res[$key] = $oItem->GetNodeAsArrayOfItems(); + else + { + $res[] = $oItem->GetNodeAsArrayOfItems(); + } + $sRank = $oItem->GetChildText('rank'); + if ($sRank != '') + { + $aRanks[] = (float) $sRank; + } + else + { + $aRanks[] = count($aRanks) > 0 ? max($aRanks) + 1 : 0; + } + array_multisort($aRanks, $res); } - else - { - $res[] = $oItem->GetNodeAsArrayOfItems(); - } - $sRank = $oItem->GetChildText('rank'); - if ($sRank != '') - { - $aRanks[] = (float) $sRank; - } - else - { - $aRanks[] = count($aRanks) > 0 ? max($aRanks) + 1 : 0; - } - array_multisort($aRanks, $res); } } else