diff --git a/src/Umbraco.Core/Models/PropertyTagsExtensions.cs b/src/Umbraco.Core/Models/PropertyTagsExtensions.cs index 41d66055f5..0cefaf2ccc 100644 --- a/src/Umbraco.Core/Models/PropertyTagsExtensions.cs +++ b/src/Umbraco.Core/Models/PropertyTagsExtensions.cs @@ -24,11 +24,11 @@ namespace Umbraco.Core.Models { if (property == null) throw new ArgumentNullException(nameof(property)); - var editor = PropertyEditors[property.Alias]; + var editor = PropertyEditors[property.PropertyType.PropertyEditorAlias]; var tagAttribute = editor.GetTagAttribute(); if (tagAttribute == null) return null; - var configurationObject = DataTypeService.GetDataType(property.PropertyType.DataTypeId); + var configurationObject = DataTypeService.GetDataType(property.PropertyType.DataTypeId).Configuration; var configuration = ConfigurationEditor.ConfigurationAs(configurationObject); if (configuration.Delimiter == default) diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs index c8c31c8e7a..95377af479 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentRepositoryBase.cs @@ -417,7 +417,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement var editorAlias = propertyTypeDto.DataTypeDto.EditorAlias; var editorAttribute = PropertyEditors[editorAlias].GetTagAttribute(); if (editorAttribute == null) continue; - var tagConfiguration = ConfigurationEditor.ConfigurationAs(propertyTypeDto.DataTypeDto.Configuration); + var tagConfigurationSource = propertyTypeDto.DataTypeDto.Configuration; + var tagConfiguration = string.IsNullOrWhiteSpace(tagConfigurationSource) + ? new TagConfiguration() + : JsonConvert.DeserializeObject(tagConfigurationSource); if (tagConfiguration.Delimiter == default) tagConfiguration.Delimiter = editorAttribute.Delimiter; tagEditors[editorAlias] = tagConfiguration; } diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs index e4337f9dac..0deb396978 100644 --- a/src/Umbraco.Core/Services/Implement/ContentService.cs +++ b/src/Umbraco.Core/Services/Implement/ContentService.cs @@ -991,6 +991,7 @@ namespace Umbraco.Core.Services.Implement if (result.Success == false) { scope.Events.Dispatch(TreeChanged, this, new TreeChange(content, changeType).ToEventArgs()); + scope.Complete(); // compete the save return result; } diff --git a/src/Umbraco.Tests/Services/TagServiceTests.cs b/src/Umbraco.Tests/Services/TagServiceTests.cs index c198871ed0..e1cf57a1e9 100644 --- a/src/Umbraco.Tests/Services/TagServiceTests.cs +++ b/src/Umbraco.Tests/Services/TagServiceTests.cs @@ -1,5 +1,6 @@ using System.Linq; using NUnit.Framework; +using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; using Umbraco.Tests.TestHelpers; @@ -18,7 +19,6 @@ namespace Umbraco.Tests.Services public class TagServiceTests : TestWithSomeContentBase { [Test] - [Explicit("Fails, tags API is not consistent.")] public void TagApiConsistencyTest() { var contentService = ServiceContext.ContentService; @@ -34,12 +34,24 @@ namespace Umbraco.Tests.Services IContent content1 = MockedContent.CreateSimpleContent(contentType, "Tagged content 1", -1); content1.AssignTags("tags", new[] { "cow", "pig", "goat" }); + content1.PublishValues(); contentService.SaveAndPublish(content1); + // change content1.AssignTags("tags", new[] { "elephant" }, true); content1.RemoveTags("tags", new[] { "cow" }); + content1.PublishValues(); contentService.SaveAndPublish(content1); + // more changes + content1.AssignTags("tags", new[] { "mouse" }, true); + content1.PublishValues(); + contentService.SaveAndPublish(content1); + content1.RemoveTags("tags", new[] { "mouse" }); + content1.PublishValues(); + contentService.SaveAndPublish(content1); + + // get it back content1 = contentService.GetById(content1.Id); var tagsValue = content1.GetValue("tags").ToString(); var tagsValues = tagsValue.Split(','); @@ -66,9 +78,9 @@ namespace Umbraco.Tests.Services var tagService = ServiceContext.TagService; var contentType = MockedContentTypes.CreateSimpleContentType("umbMandatory", "Mandatory Doc Type", true); contentType.PropertyGroups.First().PropertyTypes.Add( - new PropertyType("test", ValueStorageType.Ntext, "tags") + new PropertyType(Constants.PropertyEditors.Aliases.Tags, ValueStorageType.Ntext, "tags") { - DataTypeId = 1041 + DataTypeId = Constants.DataTypes.Tags }); contentTypeService.Save(contentType);