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,9 +13,16 @@ 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;
}