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:
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.
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
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.
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.
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.
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.
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.
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...
can you please confirm that there are definitely no tags in the database with the single characters.
2 After creating the new tag, can you please confirm if you have done any merging afterwards ?
Depending on your answers to the above, it possibly points to a bug in core, as opposed to Tag Manager package ?
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:
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.
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
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...
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
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
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...
Thanks, Nigel - and Good luck!
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
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!
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
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
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.
Editing of tags is also a challenge.
But tags are working good on frontend:
Any ideas?
Kind regards Tomasz
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
Hi Nigel, the tag has not been split out in the database. Only while editing the page in Umbraco backend.
and tags are showing correct in auto-complete:
and when I hit "Enter":
but is split out when I save page:
Regards Tomasz
Hey Tomasz
Thanks for the additional information.
A couple of questions:
Depending on your answers to the above, it possibly points to a bug in core, as opposed to Tag Manager package ?
What are your thoughts / impressions ?
Cheers, Nige
Hi Nigel,
I'm sorry. I think I have posted my problem in a wrong thread.
I don't use Tag Manager in my project, so I think it is a bug in core. I didn't have time to dig in that problem yet.
Regards Tomasz
Hi Tomasz
Appreciate your feedback which has certainly helped clarify where the issue is occurring.
Take care
Nige
is working on a reply...