From 7e21e7381e807dbecbeb28417e1516e20a9d185d Mon Sep 17 00:00:00 2001 From: rhaiamz Date: Mon, 19 Oct 2020 15:33:17 +0300 Subject: [PATCH] Ensure comments are only inserted when necessary Fix #4219 --- .../Library/Services/Installer/XmlMerge.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/DNN Platform/Library/Services/Installer/XmlMerge.cs b/DNN Platform/Library/Services/Installer/XmlMerge.cs index 90ca84f9154..d1bf22c2b25 100644 --- a/DNN Platform/Library/Services/Installer/XmlMerge.cs +++ b/DNN Platform/Library/Services/Installer/XmlMerge.cs @@ -8,7 +8,8 @@ namespace DotNetNuke.Services.Installer using System.Diagnostics; using System.IO; using System.Linq; - using System.Xml; + using System.Xml; + using System.Xml.Linq; using DotNetNuke.Application; using DotNetNuke.Common; @@ -629,7 +630,16 @@ private bool UpdateNode(XmlNode rootNode, XmlNode actionNode) var newContent = rootNode.InnerXml; changedNode = !string.Equals(oldContent, newContent, StringComparison.Ordinal); break; - case "save": + case "save": + var newChild = this.TargetConfig.ImportNode(child, true); + var targetXElement = XElement.Load(targetNode.CreateNavigator().ReadSubtree()); + var newXElement = XElement.Load(newChild.CreateNavigator().ReadSubtree()); + + if (XElement.DeepEquals(targetXElement, newXElement)) + { + break; + } + string commentHeaderText = string.Format( Localization.GetString("XMLMERGE_Upgrade", Localization.SharedResourceFile), Environment.NewLine, @@ -637,10 +647,8 @@ private bool UpdateNode(XmlNode rootNode, XmlNode actionNode) this.Version, DateTime.Now); XmlComment commentHeader = this.TargetConfig.CreateComment(commentHeaderText); - var targetNodeContent = this.GetNodeContentWithoutComment(targetNode); XmlComment commentNode = this.TargetConfig.CreateComment(targetNodeContent); - var newChild = this.TargetConfig.ImportNode(child, true); rootNode.ReplaceChild(newChild, targetNode); rootNode.InsertBefore(commentHeader, newChild); rootNode.InsertBefore(commentNode, newChild);