Adding tags works fine, and also removing tags work fine in the editor view.
However, when using ITagEngine.GetContentReferencesByTags the returned results includes the IContent where the tags were removed. Upon further investigation I found that the tags won't get deleted in TagService.RemoveOldContentTags() since the tag GroupKeydoesn't match the IContents languagebranch.
In the previous case the tag's GroupKey will be articles:sv or articles:en, but TagService.RemoveOldContentTags() will skip since it looks for sv or en specifically.
Changing tag.GroupKey != language to !tag.GroupKey.EndsWith(language) fixes this problem since the language be appended to the groupkey in TagsHelper.GetGroupKeyFromAttributes():
public static string GetGroupKeyFromAttributes(
TagsGroupKeyAttribute groupKeyAttribute,
CultureSpecificAttribute cultureSpecificAttribute,
IContent content)
{
var groupKey = string.Empty;
if (groupKeyAttribute == null && cultureSpecificAttribute == null && content is ILocalizable localizableContent)
{
groupKey += localizableContent.MasterLanguage;
}
if (groupKeyAttribute != null)
{
groupKey += groupKeyAttribute.Key;
}
if (cultureSpecificAttribute != null && cultureSpecificAttribute.IsCultureSpecific)
{
groupKey += ContentLanguage.PreferredCulture ?? CultureInfo.CurrentCulture;
}
return groupKey;
}
This happens when using a combination of culture specific and explicit group key.
The issue can be reproduced by creating property using the following configuration:
Adding tags works fine, and also removing tags work fine in the editor view. However, when using
ITagEngine.GetContentReferencesByTags
the returned results includes theIContent
where the tags were removed. Upon further investigation I found that the tags won't get deleted inTagService.RemoveOldContentTags()
since the tagGroupKey
doesn't match theIContents
languagebranch. In the previous case the tag's GroupKey will bearticles:sv
orarticles:en
, butTagService.RemoveOldContentTags()
will skip since it looks forsv
oren
specifically. Changingtag.GroupKey != language
to!tag.GroupKey.EndsWith(language)
fixes this problem since the language be appended to the groupkey inTagsHelper.GetGroupKeyFromAttributes()
: