diff --git a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml
index 2e42e2e1c..720a067d6 100755
--- a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml
+++ b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml
@@ -77,7 +77,7 @@
true
-
+
lnkContactToFunctionalCI
functionalci_id
0
diff --git a/datamodels/2.x/itop-portal/datamodel.itop-portal.xml b/datamodels/2.x/itop-portal/datamodel.itop-portal.xml
index 2fe7d8a3c..d8d9c7612 100644
--- a/datamodels/2.x/itop-portal/datamodel.itop-portal.xml
+++ b/datamodels/2.x/itop-portal/datamodel.itop-portal.xml
@@ -41,7 +41,7 @@
-
+
@@ -56,21 +56,21 @@
-
+
org_id]]>
-
+
org_id]]>
-
+
org_id]]>
@@ -145,9 +145,9 @@
-
+
-
+
diff --git a/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml b/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml
index dc2790b51..201199553 100755
--- a/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml
+++ b/datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml
@@ -277,7 +277,7 @@
}
]]>
-
+
/**
*
* Add the current contact associated Person to the contacts_list of this Ticket
@@ -305,7 +305,7 @@
}]]>
-
+
/**
*
* Remove the current user associated Person from the contacts_list of this Ticket
diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php
index a029da479..b25b249b1 100644
--- a/setup/modelfactory.class.inc.php
+++ b/setup/modelfactory.class.inc.php
@@ -2357,29 +2357,24 @@ EOF;
*/
public function ApplyChanges()
{
- $oNodes = $this->ListChanges();
- foreach ($oNodes as $oNode)
- {
- $sOperation = $oNode->GetAttribute('_alteration');
- switch ($sOperation)
- {
- case 'added':
- case 'replaced':
- case 'needed':
- case 'forced':
- // marked as added or modified, just reset the flag
- $oNode->removeAttribute('_alteration');
- break;
-
- case 'removed':
- // marked as deleted, let's remove the node from the tree
- $oNode->parentNode->removeChild($oNode);
- break;
+ // Note: omitting the dot will make the query be global to the whole document!!!
+ $oNodes = $this->ownerDocument->GetNodes('.//*[@_alteration or @_old_id or @_delta]', $this, false);;
+ foreach ($oNodes as $oNode) {
+ // _delta must not exist after applying changes
+ if ($oNode->hasAttribute('_delta')) {
+ $oNode->removeAttribute('_delta');
}
- if ($oNode->hasAttribute('_old_id'))
- {
+ if ($oNode->hasAttribute('_old_id')) {
$oNode->removeAttribute('_old_id');
}
+ if ($oNode->hasAttribute('_alteration')) {
+ if ('removed' === $oNode->GetAttribute('_alteration')) {
+ $oNode->parentNode->removeChild($oNode);
+ } else {
+ // marked as added or modified, just reset the flag
+ $oNode->removeAttribute('_alteration');
+ }
+ }
}
}
}
diff --git a/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php b/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php
index f5eff7661..5f38692af 100644
--- a/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php
+++ b/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php
@@ -727,7 +727,33 @@ XML
-
+
+
+
+
+XML
+ ];
+ $aDeltas['nested _delta should be cleaned'] = [
+ 'sInitialXML' => <<
+
+XML
+ ,
+ 'sDeltaXML' => <<
+
+
+
+
+
+
+XML
+ ,
+ 'sExpectedXML' => <<
+
+
+