Fixing another potential NRE when saving a content item with LocalizationPart for the first time

This commit is contained in:
Lombiq
2015-07-17 18:56:06 +02:00
committed by Benedek Farkas
parent ddaf49db4a
commit 81034f43d2

View File

@@ -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);
}