From 421cbf979c1cdcf8357dc8d2b91112c3a0f1567d Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 19 Oct 2018 12:47:04 +0200 Subject: [PATCH] Cleanup rollback in content service --- src/Umbraco.Core/Services/IContentService.cs | 11 +++++++---- src/Umbraco.Core/Services/Implement/ContentService.cs | 7 ++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Services/IContentService.cs b/src/Umbraco.Core/Services/IContentService.cs index 3a0f920d48..436b8e6172 100644 --- a/src/Umbraco.Core/Services/IContentService.cs +++ b/src/Umbraco.Core/Services/IContentService.cs @@ -467,10 +467,13 @@ namespace Umbraco.Core.Services /// /// Rolls back the content to a specific version. /// - /// The id of the content node - /// The version ID to rollback to - /// An optional culture - specifying a culture will only rollback the culture content - /// The user ID who is performing the rollback + /// The id of the content node. + /// The version id to roll back to. + /// An optional culture to roll back. + /// The identifier of the user who is performing the roll back. + /// + /// When no culture is specified, all cultures are rolled back. + /// OperationResult Rollback(int id, int versionId, string culture = "*", int userId = 0); #endregion diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs index ea2a2e5685..e3baff8439 100644 --- a/src/Umbraco.Core/Services/Implement/ContentService.cs +++ b/src/Umbraco.Core/Services/Implement/ContentService.cs @@ -2517,7 +2517,11 @@ namespace Umbraco.Core.Services.Implement var rollbackEventArgs = new RollbackEventArgs(content); //Emit RollingBack event aka before - scope.Events.Dispatch(RollingBack, this, rollbackEventArgs); + if (scope.Events.DispatchCancelable(RollingBack, this, rollbackEventArgs)) + { + scope.Complete(); + return OperationResult.Cancel(evtMsgs); + } //Copy the changes from the version content.CopyFrom(version, culture); @@ -2534,6 +2538,7 @@ namespace Umbraco.Core.Services.Implement else { //Emit RolledBack event aka after + rollbackEventArgs.CanCancel = false; scope.Events.Dispatch(RolledBack, this, rollbackEventArgs); //Logging & Audit message