Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ferdy Hoefakker 214 posts 248 karma points
    Jan 06, 2017 @ 12:34
    Ferdy Hoefakker
    0

    Inconsistency with regular content types

    Hi,

    I seem to have stumbled upon an inconsistency with Nested Content compared to normal content types.

    When I have a textbox, enter data and save the node it gets written to the umbraco.config like so:

    <propertyName><![CDATA[Text goes here]]></propertyName>
    

    If I then remove the text from the box, the entire property is removed from the umbraco.config.

    Nested Content saves the JSON data the same way. This is all fine and as expected.

    HOWEVER. Upon deleting all items from my Nested Content, it will still save as JSON data with an empty array like so:

    <nestedContentProperty><![CDATA[[]]]></nestedContentProperty>
    

    This means the property isn't removed from the umbraco.config. Which causes an inconsistency with the way GetPropertyValue<>() works.

    Because when I try to retrieve this data recursively, like so:

    ipublishedContent.GetPropertyValue<IEnumerable<IPublishedContent>>("propertyName", true)
    

    it will ALWAYS get a result back, in this case an empty IEnumberable. This means it won't look at the parents node value. It will just decide that the current node has the data I need.

    In my opinion, this is inconsistent with how the other property types work and would love to see this changed.

    -Ferdy

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jan 06, 2017 @ 12:47
    Lee Kelleher
    0

    Hi Ferdy,

    Thanks for raising this... it's a very good point! :-)

    I guess there are 2 things happening here, first is that the property value in the XML cache is being set as an empty string - not sure why.

    The second is that GetPropertyValue tries to get the object value from NestedContent's PropertyValueConverter - that ultimately calls this code...

    https://github.com/umco/umbraco-nested-content/blob/develop/src/Our.Umbraco.NestedContent/Extensions/PublishedPropertyTypeExtensions.cs#L43

    Strange thing is that NC's code checks if the value is null or empty string, so it should be returning a null reference instead. Hmmm.

    How are your dev skills? Would you be interested in looking into this further? (If not, no worries, it'll probably be a few weeks before I get around to it - due to heavy workload)


    Alternatively, I recall a similar issue I had with Archetype... I ended up writing an extension method to handle the recursive value checker...
    https://gist.github.com/leekelleher/8e85a1020179edfad29a


    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft