Geta / geta-optimizely-genericlinks

An extensive alternative to LinkItemCollection in Optimizely.
Apache License 2.0
4 stars 0 forks source link

LinkData is not copied when using 'Duplicate Content' from Language gadget #27

Closed joerg-seibert-syzygy closed 9 months ago

joerg-seibert-syzygy commented 10 months ago

When LinkData (in our case a sub-class of LinkData) is used in content and respective property is culture-specific, duplicating content from Language gadget does not respect LinkData property. image

After new content (block/page) is created (from duplication context menu), LinkData property is empty.

Property: [CultureSpecific] public virtual ExtendedLinkData? Link { get; set; }

public class ExtendedLinkData : LinkData ...

This happens with Versions 1.8.1 and 1.8.2

UPDATE: Language variants are created with LanguageBranchManager in method CopyDataForNestedContentRecursive where the value of property (of type LinkData) is assigned to property of duplicated/cloned content using PropertyData instances. This assignment is directly assigning to private field _linkData of class Geta.Optimizely.GenericLinks.PropertyLinkData. As source property value is not modified, destination value will neither be in modified state. When I override Value property in our code (PropertyExtendedLink : PropertyLinkData) and assign value in this way if (value is ExtendedLinkData linkData2) { Link = linkData2; } else { base.Value = value; } which implicitly sets IsModified to true, the language variant will have set the correct LinkData value.

svenrog commented 9 months ago

I've submitted a version containing a fix (1.8.3) to the Optimizely NuGet feed. The new version is setting the properties Link and Links instead of directly accessing the private fields when setting Value. It should be available in a couple of hours.

svenrog commented 9 months ago

Closing due to inactivity