From e309f2d40da843372b1e442d3db38e24957fb888 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Tue, 21 May 2024 13:39:17 +0200 Subject: [PATCH] Move publishing notification after validation --- src/Umbraco.Core/Services/ContentService.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 839a5afe905d..e723bfcdd284 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1487,6 +1487,14 @@ void SaveDocument(IContent c) notificationState); if (publishResult.Success) { + // raise Publishing notification + if (scope.Notifications.PublishCancelable( + new ContentPublishingNotification(content, eventMessages).WithState(notificationState))) + { + _logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "publishing was cancelled"); + return new PublishResult(PublishResultType.FailedPublishCancelledByEvent, eventMessages, content); + } + // note: StrategyPublish flips the PublishedState to Publishing! publishResult = StrategyPublish(content, culturesPublishing, culturesUnpublishing, eventMessages); @@ -3065,14 +3073,6 @@ private PublishResult StrategyCanPublish( IReadOnlyCollection allLangs, IDictionary? notificationState) { - // raise Publishing notification - if (scope.Notifications.PublishCancelable( - new ContentPublishingNotification(content, evtMsgs).WithState(notificationState))) - { - _logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "publishing was cancelled"); - return new PublishResult(PublishResultType.FailedPublishCancelledByEvent, evtMsgs, content); - } - var variesByCulture = content.ContentType.VariesByCulture(); // If it's null it's invariant