From 9a2eaf7ac9a4cc96e55fcd73eef2a9f26e49ca43 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 8 Jul 2015 22:45:52 +0100 Subject: [PATCH] #5489: Handling potential null value for MediaLibraryPickerField.MediaParts. This happens when a content type has both a MediaLibraryPickerField and the LayoutPart attached. The layout editor renders the field, whose shape template accesses the MediaParts property, which is not initialized for new content items. Fixes #5489 --- .../Orchard.MediaLibrary/Fields/MediaLibraryPickerField.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Fields/MediaLibraryPickerField.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Fields/MediaLibraryPickerField.cs index d2ef6c94f..a745a5536 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Fields/MediaLibraryPickerField.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Fields/MediaLibraryPickerField.cs @@ -7,7 +7,7 @@ using Orchard.MediaLibrary.Models; namespace Orchard.MediaLibrary.Fields { public class MediaLibraryPickerField : ContentField { - private static readonly char[] separator = new [] {'{', '}', ','}; + private static readonly char[] separator = {'{', '}', ','}; internal Lazy> _contentItems; public int[] Ids { @@ -17,7 +17,7 @@ namespace Orchard.MediaLibrary.Fields { public IEnumerable MediaParts { get { - return _contentItems.Value; + return _contentItems != null ? _contentItems.Value : Enumerable.Empty(); } }