mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 03:58:13 +08:00
Preventing TimeZone from crashing if the migration cannot run before using it
--HG-- branch : 1.x
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user