November Happy Hour will be moved to Thursday December 5th.

PropertyLinkCollection loses all links if RemapPermanentLinkReferences is called

Found in

EPiServer.CMS.Core 9.12.0

Fixed in

EPiServer.CMS.Core 10.0.1

(Or a related package)

Created

Aug 17, 2016

Updated

Nov 08, 2016

Area

CMS Core

State

Closed, Fixed and tested


Description

The PropertyLinkCollection inherits from PropertyXhtmlString but doesn't populate the XhtmlString value if the value is set to a LinkCollection.

This has a few side effects, primarily that all links are removed if RemapPermanentLinkReferences is called.

Example unit test from PropertyLinkCollectionTest.cs.

[Fact]
public void RemapPermanentLinkReferences_WhenLinksAreSet_ShouldRemapLinks()
{
    var originalGuid = Guid.NewGuid();
    var remappedGuid = Guid.NewGuid();
 
    var property = new PropertyLinkCollection();
    property.Links = new LinkItemCollection { new LinkItem { Href = PermanentLinkUtility.GetPermanentLinkVirtualPath(originalGuid, ".txt"), UrlResolver = UrlResolver() } };
 
    var map = new Dictionary<Guid, Guid> { { originalGuid, remappedGuid } };
 
    property.RemapPermanentLinkReferences(map);
 
    var expected = PermanentLinkUtility.GetPermanentLinkVirtualPath(remappedGuid, ".txt");
 
    Assert.Equal(expected, property.Links[1].Href);
}

Breaking Changes

  • PropertyLinkCollection no longer inherits PropertyXhtmlString. It is now a direct base class to PropertyLongString, which means that properties and methods inherited from PropertyXhtmlString are no longer available.