Skip to content

Commit

Permalink
Ensure comments are only inserted when necessary
Browse files Browse the repository at this point in the history
Fix #4219
  • Loading branch information
rhaiamz authored and bdukes committed Oct 19, 2020
1 parent 4e657a8 commit a9d2dd7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions DNN Platform/Library/Services/Installer/XmlMerge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -629,18 +630,25 @@ 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,
this.Sender,
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);
Expand Down

0 comments on commit a9d2dd7

Please sign in to comment.