Preventing TimeZone from crashing if the migration cannot run before using it

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-01-12 18:31:40 -08:00
parent fc99676fe0
commit d61e98e010

View File

@@ -13,12 +13,19 @@ namespace Orchard.Time {
} }
public TimeZoneSelectorResult GetTimeZone(HttpContextBase context) { 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 null;
} }
return new TimeZoneSelectorResult { return new TimeZoneSelectorResult {
Priority = -5, Priority = -5,
TimeZone = TimeZoneInfo.FindSystemTimeZoneById(siteTimeZoneId) TimeZone = TimeZoneInfo.FindSystemTimeZoneById(siteTimeZoneId)