From d61e98e0104ca41bc856526376e971da8e3907bf Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 12 Jan 2012 18:31:40 -0800 Subject: [PATCH] Preventing TimeZone from crashing if the migration cannot run before using it --HG-- branch : 1.x --- src/Orchard/Time/SiteTimeZoneSelector.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Orchard/Time/SiteTimeZoneSelector.cs b/src/Orchard/Time/SiteTimeZoneSelector.cs index 300d5548e..76e8e093d 100644 --- a/src/Orchard/Time/SiteTimeZoneSelector.cs +++ b/src/Orchard/Time/SiteTimeZoneSelector.cs @@ -13,12 +13,19 @@ namespace Orchard.Time { } public TimeZoneSelectorResult GetTimeZone(HttpContextBase context) { - var siteTimeZoneId = _workContextAccessor.GetContext(context).CurrentSite.SiteTimeZone; - if (String.IsNullOrEmpty(siteTimeZoneId)) { + try { + var siteTimeZoneId = _workContextAccessor.GetContext(context).CurrentSite.SiteTimeZone; + + if (String.IsNullOrEmpty(siteTimeZoneId)) { + return null; + } + } + catch { + // if the database could not be updated in time, ignore this provider return null; } - + return new TimeZoneSelectorResult { Priority = -5, TimeZone = TimeZoneInfo.FindSystemTimeZoneById(siteTimeZoneId)