From 81034f43d2f9886f5cbf10618091bce56f96c946 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Fri, 17 Jul 2015 18:56:06 +0200 Subject: [PATCH] Fixing another potential NRE when saving a content item with LocalizationPart for the first time --- .../Orchard.Localization/Drivers/LocalizationPartDriver.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Localization/Drivers/LocalizationPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Localization/Drivers/LocalizationPartDriver.cs index fc30e15aa..01f4cb3e0 100644 --- a/src/Orchard.Web/Modules/Orchard.Localization/Drivers/LocalizationPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Localization/Drivers/LocalizationPartDriver.cs @@ -61,8 +61,9 @@ namespace Orchard.Localization.Drivers { protected override DriverResult Editor(LocalizationPart part, IUpdateModel updater, dynamic shapeHelper) { var model = new EditLocalizationViewModel(); - // Content culture has to be set only if it's not set already. - if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null) && GetCulture(part) == null) { + // GetCulture(part) is checked against null value, because the content culture has to be set only if it's not set already. + // model.SelectedCulture is checked against null value, because the editor group may not contain LocalizationPart when the content item is saved for the first time. + if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null) && GetCulture(part) == null && !string.IsNullOrEmpty(model.SelectedCulture)) { _localizationService.SetContentCulture(part, model.SelectedCulture); }