Copied to clipboard

Flag this post as spam?

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


  • Heather Floyd 459 posts 565 karma points c-trib
    Dec 13, 2018 @ 18:56
    Heather Floyd
    0

    Bug on "Merge Tags" - Corrupted Property data

    I am using Tag Manager in a brand new Umbraco version 7.12.4 site. I noticed something strange when using the "Merge Tags" option - the tag property actually gets corrupted on the content node.

    For example, I have a tag which is assigned to a content node's property. In Tag Manager I go tot hat tag and "Merge Tags" to another existing tag ("Culture"). When I look at the content node, this is what I see: Corrupted Tag Property

    When attempting to access this data (in a content model or view), a JSON error is returned. I am unable to use the little trash icons on the property to delete these non-tags. The only way to get rid of the corruption is to programmatically use the ContentService to set a new value on the property.

    The tags property datatype is using the JSON storage method.

  • Nigel Wilson 867 posts 1839 karma points
    Dec 13, 2018 @ 19:53
    Nigel Wilson
    0

    Hi Heather

    "good" to hear from you... haha :-)

    Yeah that is definitely a very weird issue.

    I will need to spin up a site locally to figure the issue out - might be a few days before I can get onto it.

    Being the merge functionality I trust it isn't a show stopper for you at the moment ?

    I'll update when I've had a look.

    Cheers Nigel

  • Heather Floyd 459 posts 565 karma points c-trib
    Dec 13, 2018 @ 20:21
    Heather Floyd
    0

    Thanks, Nigel!

    That's fine :-)

    I was just doing a big content import and cleaning up tags when I noticed this issue. I've written some code that uses the ContentService to repair these bad entries (fortunately I have reference data stored in a separate property I can use to re-set these correctly)

    Snippet here in case it helps...

        private string TestAndFixCatsAndTags(IPublishedContent post, ref IContent postContent)
        {
            //NOTE: 'postContent' is created and saved/published in a calling function (hence being passed in as a ref)
            var returnMessage = "No changes made";
    
            if (postContent != null)
            {
                try
                {
                    IEnumerable<string> postTags;
                    IEnumerable<string> postCategories;
                    try
                    {
                        postTags = post.GetPropertyValue<IEnumerable<string>>("Tags").ToList();
                    }
                    catch (Exception e)
                    {
                        //bad values in Tags, return empty
                        postTags = new List<string>();
                    }
    
                    try
                    {
                        postCategories = post.GetPropertyValue<IEnumerable<string>>("Categories").ToList();
                    }
                    catch (Exception e)
                    {
                        //bad values in Categories, return empty
                        postCategories = new List<string>();
                    }
    
                    //Set Custom Categories based on Tags
                    if (!postCategories.Any() && postTags.Any())
                    {
                        var newCategories = GetNewCategories(postTags).ToList();
                        postContent.SetTags(TagCacheStorageType.Json, "Categories", newCategories, true, "BlogCategories");
                           returnMessage = $"Categories fixed to '{string.Join(", ", newCategories)}'.";
                    }
                    //Copy Categories to Tags
                    else if (!postTags.Any() && postCategories.Any())
                    {
                        postContent.SetTags(TagCacheStorageType.Json, "Tags", postCategories,true, "BlogTags");
                        returnMessage = $"Tags fixed to '{string.Join(", ", postCategories)}'.";
                    }
                    //Copy Imported Categories to Tags & Categories
                    else if (!postTags.Any() && !postCategories.Any())
                    {
                        var postImportCategories = post.GetPropertyValue<string>("ImportCategories");
                        var importedTags = postImportCategories.Split(',').ToList();
                        if (importedTags.Any())
                        {
                            postContent.SetTags(TagCacheStorageType.Json, "Tags", importedTags, true, "BlogTags");
    
                            var newCategories = GetNewCategories(importedTags).ToList();
                            postContent.SetTags(TagCacheStorageType.Json, "Categories", newCategories, true, "BlogCategories");
    
                            returnMessage = $"Categories fixed to '{string.Join(", ", newCategories)}' & Tags fixed to '{string.Join(", ", importedTags)}'.";
                        }
                    }
                }
                catch (Exception ex)
                {
                    var msg = $"ERROR FIXING POST {post.Id}";
                    LogHelper.Warn<BlogViewerApiController>(msg);
                    returnMessage = msg + $" : {ex.Message}";
                }
            }
    
            return returnMessage;
        }
    

    Ps. I just want to tell you how much I appreciate this package - the interface and functionality is fantastic! Thanks so much for devoting the time to maintain it, also. <3

  • Nigel Wilson 867 posts 1839 karma points
    Dec 13, 2018 @ 20:56
    Nigel Wilson
    0

    Too helpful and thanks for your kind words, it is very much appreciated. It is nice to be able to give something back to the community after receiving so much support over the years.

    Wishing you and yours a Merry Xmas

    N

  • Nigel Wilson 867 posts 1839 karma points
    18 days ago
    Nigel Wilson
    0

    Hi Heather - just letting you know I've finally gotten started on this one.

    I have a V7.8 site running with starter kit - the merge is working OK on that version, so will step through the releases until things break.

    Stay tuned - the wheels have started turning...

  • Heather Floyd 459 posts 565 karma points c-trib
    18 days ago
    Heather Floyd
    0

    Thanks, Nigel - and Good luck!

  • Nigel Wilson 867 posts 1839 karma points
    18 days ago
    Nigel Wilson
    0

    Hi Heather

    I have tested the package against all major version through to 7.13 (and also 7.12.4) and encountered no problems so far - the merge functionality is working as expected.

    Guess the next best thing will be to spin up a fresh install of 7.12.4 and see how that goes - in creating the site I am using the Starter Kit which has tags already linked to content, so assuming it will be a good test.

    Will update once I've tried the above.

    Cheers, Nigel

  • Heather Floyd 459 posts 565 karma points c-trib
    17 days ago
    Heather Floyd
    0

    Hi Nigel, Hmm... perhaps it had something to do with the way the tags got stored on my initial content import... or something... I'm not sure. Well, if you can't reproduce it, then I guess it's a fluke.

    Thanks for checking into it, though!

  • Nigel Wilson 867 posts 1839 karma points
    1 week ago
    Nigel Wilson
    0

    Hi Heather

    I have just installed a starter kit on a clean install of 7.12.4 and sorry I haven't been able to reproduce the issue you described.

    Just wondering - have you tried reinstalling the Tag Manager package again (over the top of the existing). Doubt it will make any difference, just a thought.

    Cheers

    Nigel

  • Nigel Wilson 867 posts 1839 karma points
    1 week ago
    Nigel Wilson
    0

    Hi Heather

    Just wondering the "where to from here" - are you able to try installing a fresh starter kit site and see how it goes for you ?

    I am a bit a hamstrung due to not being able to replicate.

    Cheers

    Nigel

  • Tomasz Kowalski 68 posts 210 karma points
    1 day ago
    Tomasz Kowalski
    0

    Hi I have just seen it on one of our customers website. It was Umbraco 7.12.4. I have updated it to the newest 7.13.2, but it didn't helped. Problem persists.

    tags-backend

    Editing of tags is also a challenge.

    But tags are working good on frontend:

    tags-frontend

    Any ideas?

    Kind regards Tomasz

  • Nigel Wilson 867 posts 1839 karma points
    1 day ago
    Nigel Wilson
    0

    Hi Tomasz and Heather

    Firstly, thanks Tomasz for your feedback - good to hear (I think) that the issue has happened to someone else too.

    Just a thought...

    Whilst I think it will be the case, are you able to check the database directly to verify the tag has been split out like it is being shown. Like I said, it makes sense that it has given how it is being displayed, but it doesn't hurt to double check...

    Look forward to hearing form you.

    Thanks

    Nigel

  • Tomasz Kowalski 68 posts 210 karma points
    1 day ago
    Tomasz Kowalski
    0

    Hi Nigel, the tag has not been split out in the database. Only while editing the page in Umbraco backend.

    tags-database

    and tags are showing correct in auto-complete:

    autocomplete

    and when I hit "Enter":

    enter

    but is split out when I save page:

    split

    Regards Tomasz

  • Nigel Wilson 867 posts 1839 karma points
    1 day ago
    Nigel Wilson
    0

    Hey Tomasz

    Thanks for the additional information.

    So in creating the new tag you haven't done any merging ?

    If so, then this possibly points to a bug in core, as opposed to Tag Manager package ?

    What are your thoughts / impressions ?

    Cheers, Nige

Please Sign in or register to post replies

Write your reply to:

Draft