diff --git a/src/Umbraco.Core/Models/ContentEditing/DocumentTypeDisplay.cs b/src/Umbraco.Core/Models/ContentEditing/DocumentTypeDisplay.cs index 1fa0895f61..3bb52c39b7 100644 --- a/src/Umbraco.Core/Models/ContentEditing/DocumentTypeDisplay.cs +++ b/src/Umbraco.Core/Models/ContentEditing/DocumentTypeDisplay.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.Serialization; namespace Umbraco.Cms.Core.Models.ContentEditing @@ -16,7 +16,8 @@ namespace Umbraco.Cms.Core.Models.ContentEditing [DataMember(Name = "allowedTemplates")] public IEnumerable AllowedTemplates { get; set; } - [DataMember(Name = "defaultTemplate")] public EntityBasic DefaultTemplate { get; set; } + [DataMember(Name = "defaultTemplate")] + public EntityBasic DefaultTemplate { get; set; } [DataMember(Name = "allowCultureVariant")] public bool AllowCultureVariant { get; set; } @@ -24,8 +25,10 @@ namespace Umbraco.Cms.Core.Models.ContentEditing [DataMember(Name = "allowSegmentVariant")] public bool AllowSegmentVariant { get; set; } - [DataMember(Name = "apps")] public IEnumerable ContentApps { get; set; } + [DataMember(Name = "apps")] + public IEnumerable ContentApps { get; set; } - [DataMember(Name = "historyCleanup")] public HistoryCleanupViewModel HistoryCleanup { get; set; } + [DataMember(Name = "historyCleanup")] + public HistoryCleanupViewModel HistoryCleanup { get; set; } } } diff --git a/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs b/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs index 5e7b34b0bf..b7bfb32808 100644 --- a/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs +++ b/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs @@ -5,7 +5,8 @@ namespace Umbraco.Cms.Core.Models.ContentEditing [DataContract(Name = "historyCleanup", Namespace = "")] public class HistoryCleanup { - [DataMember(Name = "preventCleanup")] public bool PreventCleanup { get; set; } + [DataMember(Name = "preventCleanup")] + public bool PreventCleanup { get; set; } [DataMember(Name = "keepAllVersionsNewerThanDays")] public int? KeepAllVersionsNewerThanDays { get; set; } diff --git a/src/Umbraco.Core/Models/ContentEditing/HistoryCleanupViewModel.cs b/src/Umbraco.Core/Models/ContentEditing/HistoryCleanupViewModel.cs index 94423a8060..303ff4eda3 100644 --- a/src/Umbraco.Core/Models/ContentEditing/HistoryCleanupViewModel.cs +++ b/src/Umbraco.Core/Models/ContentEditing/HistoryCleanupViewModel.cs @@ -5,13 +5,14 @@ namespace Umbraco.Cms.Core.Models.ContentEditing [DataContract(Name = "historyCleanup", Namespace = "")] public class HistoryCleanupViewModel : HistoryCleanup { - [DataMember(Name = "globalKeepAllVersionsNewerThanDays")] - public int? GlobalKeepAllVersionsNewerThanDays { get;set; } - - [DataMember(Name = "globalKeepLatestVersionPerDayForDays")] - public int? GlobalKeepLatestVersionPerDayForDays { get; set;} [DataMember(Name = "globalEnableCleanup")] public bool GlobalEnableCleanup { get; set; } + + [DataMember(Name = "globalKeepAllVersionsNewerThanDays")] + public int? GlobalKeepAllVersionsNewerThanDays { get; set; } + + [DataMember(Name = "globalKeepLatestVersionPerDayForDays")] + public int? GlobalKeepLatestVersionPerDayForDays { get; set; } } } diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index a2357e21ef..6ff94f57f3 100644 --- a/src/Umbraco.Core/Models/ContentType.cs +++ b/src/Umbraco.Core/Models/ContentType.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; @@ -17,9 +17,8 @@ namespace Umbraco.Cms.Core.Models { public const bool SupportsPublishingConst = true; - - //Custom comparer for enumerable - private static readonly DelegateEqualityComparer> TemplateComparer = new( + // Custom comparer for enumerable + private static readonly DelegateEqualityComparer> TemplateComparer = new ( (templates, enumerable) => templates.UnsortedSequenceEqual(enumerable), templates => templates.GetHashCode()); @@ -88,8 +87,7 @@ namespace Umbraco.Cms.Core.Models get => _allowedTemplates; set { - SetPropertyValueAndDetectChanges(value, ref _allowedTemplates, nameof(AllowedTemplates), - TemplateComparer); + SetPropertyValueAndDetectChanges(value, ref _allowedTemplates, nameof(AllowedTemplates), TemplateComparer); if (_allowedTemplates.Any(x => x.Id == _defaultTemplate) == false) { diff --git a/src/Umbraco.Core/Models/ContentVersionCleanupPolicySettings.cs b/src/Umbraco.Core/Models/ContentVersionCleanupPolicySettings.cs index b23e6c95fa..5fa0e98958 100644 --- a/src/Umbraco.Core/Models/ContentVersionCleanupPolicySettings.cs +++ b/src/Umbraco.Core/Models/ContentVersionCleanupPolicySettings.cs @@ -5,9 +5,13 @@ namespace Umbraco.Cms.Core.Models public class ContentVersionCleanupPolicySettings { public int ContentTypeId { get; set; } - public int? KeepAllVersionsNewerThanDays { get; set; } - public int? KeepLatestVersionPerDayForDays { get; set; } + public bool PreventCleanup { get; set; } + + public int? KeepAllVersionsNewerThanDays { get; set; } + + public int? KeepLatestVersionPerDayForDays { get; set; } + public DateTime Updated { get; set; } } } diff --git a/src/Umbraco.Core/Models/IContentType.cs b/src/Umbraco.Core/Models/IContentType.cs index 4025239a3f..a01e612887 100644 --- a/src/Umbraco.Core/Models/IContentType.cs +++ b/src/Umbraco.Core/Models/IContentType.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Umbraco.Cms.Core.Models.ContentEditing; @@ -13,7 +13,6 @@ namespace Umbraco.Cms.Core.Models HistoryCleanup HistoryCleanup { get; set; } } - /// /// Defines a ContentType, which Content is based on /// diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs index f0350d9f1b..4b2faa166f 100644 --- a/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs +++ b/src/Umbraco.Infrastructure/Persistence/Dtos/ContentVersionCleanupPolicyDto.cs @@ -4,7 +4,6 @@ using NPoco; using Umbraco.Cms.Core; using Umbraco.Cms.Infrastructure.Persistence.DatabaseAnnotations; - namespace Umbraco.Cms.Infrastructure.Persistence.Dtos { [TableName(TableName)] @@ -18,6 +17,9 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos [ForeignKey(typeof(ContentTypeDto), Column = "nodeId", OnDelete = Rule.Cascade)] public int ContentTypeId { get; set; } + [Column("preventCleanup")] + public bool PreventCleanup { get; set; } + [Column("keepAllVersionsNewerThanDays")] [NullSetting(NullSetting = NullSettings.Null)] public int? KeepAllVersionsNewerThanDays { get; set; } @@ -26,9 +28,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos [NullSetting(NullSetting = NullSettings.Null)] public int? KeepLatestVersionPerDayForDays { get; set; } - [Column("preventCleanup")] - public bool PreventCleanup { get; set; } - [Column("updated")] public DateTime Updated { get; set; } } diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs index 0df72cd2f6..6ab97c971f 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Logging; @@ -305,7 +305,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement Updated = DateTime.Now, PreventCleanup = entityWithHistoryCleanup.HistoryCleanup.PreventCleanup, KeepAllVersionsNewerThanDays = entityWithHistoryCleanup.HistoryCleanup.KeepAllVersionsNewerThanDays, - KeepLatestVersionPerDayForDays = entityWithHistoryCleanup.HistoryCleanup.KeepLatestVersionPerDayForDays, + KeepLatestVersionPerDayForDays = entityWithHistoryCleanup.HistoryCleanup.KeepLatestVersionPerDayForDays }; Database.InsertOrUpdate(dto); } diff --git a/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs b/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs index f8669a77b4..04b93bdd9f 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs @@ -74,19 +74,19 @@ namespace Umbraco.Cms.Core.Services.Implement { EventMessages evtMsgs = EventMessagesFactory.Get(); - //Get the current copy of the node + // Get the current copy of the node IContent content = GetById(id); - //Get the version + // Get the version IContent version = GetVersion(versionId); - //Good ole null checks + // Good old null checks if (content == null || version == null || content.Trashed) { return new OperationResult(OperationResultType.FailedCannot, evtMsgs); } - //Store the result of doing the save of content for the rollback + // Store the result of doing the save of content for the rollback OperationResult rollbackSaveResult; using (IScope scope = ScopeProvider.CreateScope()) @@ -98,16 +98,16 @@ namespace Umbraco.Cms.Core.Services.Implement return OperationResult.Cancel(evtMsgs); } - //Copy the changes from the version + // Copy the changes from the version content.CopyFrom(version, culture); - //Save the content for the rollback + // Save the content for the rollback rollbackSaveResult = Save(content, userId); - //Depending on the save result - is what we log & audit along with what we return + // Depending on the save result - is what we log & audit along with what we return if (rollbackSaveResult.Success == false) { - //Log the error/warning + // Log the error/warning _logger.LogError( "User '{UserId}' was unable to rollback content '{ContentId}' to version '{VersionId}'", userId, id, versionId); @@ -117,7 +117,7 @@ namespace Umbraco.Cms.Core.Services.Implement scope.Notifications.Publish( new ContentRolledBackNotification(content, evtMsgs).WithStateFrom(rollingBackNotification)); - //Logging & Audit message + // Logging & Audit message _logger.LogInformation("User '{UserId}' rolled back content '{ContentId}' to version '{VersionId}'", userId, id, versionId); Audit(AuditType.RollBack, userId, id, @@ -1799,6 +1799,7 @@ namespace Umbraco.Cms.Core.Services.Implement publishing &= tryPublish; //set the culture to be published if (!publishing) { + continue; } } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js b/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js index 81888d574d..4db5af883e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js @@ -63,7 +63,7 @@ var saveModel = _.pick(displayModel, 'compositeContentTypes', 'isContainer', 'allowAsRoot', 'allowedTemplates', 'allowedContentTypes', 'alias', 'description', 'thumbnail', 'name', 'id', 'icon', 'trashed', - 'key', 'parentId', 'alias', 'path', 'allowCultureVariant', 'allowSegmentVariant', 'isElement','historyCleanup'); + 'key', 'parentId', 'alias', 'path', 'allowCultureVariant', 'allowSegmentVariant', 'isElement', 'historyCleanup'); saveModel.allowedTemplates = _.map(displayModel.allowedTemplates, function (t) { return t.alias; }); saveModel.defaultTemplate = displayModel.defaultTemplate ? displayModel.defaultTemplate.alias : null; diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentVersionCleanupServiceTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentVersionCleanupServiceTest.cs index 9434a2bdb3..08200a6f7e 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentVersionCleanupServiceTest.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentVersionCleanupServiceTest.cs @@ -20,6 +20,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services public IContentTypeService ContentTypeService => GetRequiredService(); public IContentService ContentService => GetRequiredService(); + public IContentVersionService ContentVersionService => GetRequiredService(); /// @@ -29,7 +30,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services [Test] public void PerformContentVersionCleanup_WithNoKeepPeriods_DeletesEverythingExceptActive() { - // For reference currently has + // For reference, Our currently has // 5000 Documents // With 200K Versions // With 11M Property data @@ -38,12 +39,12 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services FileService.SaveTemplate(template); ContentType contentTypeA = ContentTypeBuilder.CreateSimpleContentType("contentTypeA", "contentTypeA", defaultTemplateId: template.Id); + // Kill all historic contentTypeA.HistoryCleanup.PreventCleanup = false; contentTypeA.HistoryCleanup.KeepAllVersionsNewerThanDays = 0; contentTypeA.HistoryCleanup.KeepLatestVersionPerDayForDays = 0; - ContentTypeService.Save(contentTypeA); Content content = ContentBuilder.CreateSimpleContent(contentTypeA); diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Scheduling/ContentVersionCleanupTest.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Scheduling/ContentVersionCleanupTest.cs index ad06bc2683..430cd184c1 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Scheduling/ContentVersionCleanupTest.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Scheduling/ContentVersionCleanupTest.cs @@ -139,7 +139,6 @@ namespace Umbraco.Tests.Scheduling mainDom.Setup(x => x.IsMainDom).Returns(true); serverRoleAccessor.Setup(x => x.CurrentServerRole).Returns(ServerRole.SchedulingPublisher); - await sut.PerformExecuteAsync(null); cleanupService.Verify(x => x.PerformContentVersionCleanup(It.IsAny()), Times.Once); diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs index 800bcd65b7..db258c5fa1 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/DefaultContentVersionCleanupPolicyTest.cs @@ -261,6 +261,5 @@ namespace Umbraco.Tests.Services Assert.AreEqual(6, results.Single(x => x.ContentTypeId == 2).VersionId); }); } - } } diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/MemberControllerUnitTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/MemberControllerUnitTests.cs index b70b6ae658..d1ce62242e 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/MemberControllerUnitTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Web.BackOffice/Controllers/MemberControllerUnitTests.cs @@ -503,8 +503,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.BackOffice.Controllers mockShortStringHelper, globalSettings, new Mock().Object, - new Mock>().Object - ) + new Mock>().Object) }); var scopeProvider = Mock.Of(x => x.CreateScope( It.IsAny(),