From 3ecf4144e7f1dfd21526e0d0b23bfe053cbc2ec0 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 19 Feb 2019 02:51:05 +1100 Subject: [PATCH] Fixes publishing new variant content that has validation errors --- src/Umbraco.Web/Editors/ContentController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 71772bd9c5..12047b628b 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -1201,6 +1201,10 @@ namespace Umbraco.Web.Editors variant.Publish = false; } + //At this stage all variants might have failed validation which means there are no cultures flagged for publishing! + var culturesToPublish = cultureVariants.Where(x => x.Publish).Select(x => x.Culture).ToArray(); + canPublish = canPublish && culturesToPublish.Length > 0; + if (canPublish) { //try to publish all the values on the model - this will generally only fail if someone is tampering with the request @@ -1210,8 +1214,6 @@ namespace Umbraco.Web.Editors if (canPublish) { - var culturesToPublish = cultureVariants.Where(x => x.Publish).Select(x => x.Culture).ToArray(); - //proceed to publish if all validation still succeeds var publishStatus = Services.ContentService.SaveAndPublish(contentItem.PersistedContent, culturesToPublish, Security.CurrentUser.Id); wasCancelled = publishStatus.Result == PublishResultType.FailedPublishCancelledByEvent;