From 4741f33e28343f6811b3b77cd06c2a2619f65ac9 Mon Sep 17 00:00:00 2001 From: Dave Reed Date: Mon, 6 Dec 2010 13:37:11 -0800 Subject: [PATCH] #16911: Prevent YSOD when a gallery feed doesn't respond or responds unexpectedly. --HG-- branch : dev --- .../Controllers/GalleryController.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs index b2fe8d8bd..57654a990 100644 --- a/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs +++ b/src/Orchard.Web/Modules/Orchard.Packaging/Controllers/GalleryController.cs @@ -1,10 +1,12 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Web.Hosting; using System.Web.Mvc; using System.Xml.Linq; using Orchard.Environment.Extensions; using Orchard.Localization; +using Orchard.Logging; using Orchard.Packaging.Services; using Orchard.Packaging.ViewModels; using Orchard.Themes; @@ -30,9 +32,11 @@ namespace Orchard.Packaging.Controllers { _notifier = notifier; T = NullLocalizer.Instance; + Logger = NullLogger.Instance; } public Localizer T { get; set; } + public ILogger Logger { get; set; } public ActionResult Sources() { return View(new PackagingSourcesViewModel { @@ -99,8 +103,20 @@ namespace Orchard.Packaging.Controllers { : _packagingSourceManager.GetSources() ; + IEnumerable extensions = null; + foreach (var source in sources) { + try { + var sourceExtensions = _packagingSourceManager.GetModuleList(source).ToArray(); + extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions); + } + catch (Exception ex) { + Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message); + _notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message)); + } + } + return View("Modules", new PackagingExtensionsViewModel { - Extensions = sources.SelectMany(source => _packagingSourceManager.GetModuleList(source)), + Extensions = extensions ?? new PackagingEntry[] {}, Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle), SelectedSource = selectedSource });