Commit 3f9bfb0c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'blackst0ne-rails5-fix-tzinfo-invalid-timezone-identifier' into 'master'

[Rails5] Fix `TZInfo::InvalidTimezoneIdentifier` exception

See merge request gitlab-org/gitlab-ce!18640
parents aaf2f902 b26a3f91
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
def initialize(cron, cron_timezone = 'UTC') def initialize(cron, cron_timezone = 'UTC')
@cron = cron @cron = cron
@cron_timezone = ActiveSupport::TimeZone.find_tzinfo(cron_timezone).name @cron_timezone = timezone_name(cron_timezone)
end end
def next_time_from(time) def next_time_from(time)
...@@ -24,6 +24,12 @@ module Gitlab ...@@ -24,6 +24,12 @@ module Gitlab
private private
def timezone_name(timezone)
ActiveSupport::TimeZone.find_tzinfo(timezone).name
rescue TZInfo::InvalidTimezoneIdentifier
timezone
end
# NOTE: # NOTE:
# cron_timezone can only accept timezones listed in TZInfo::Timezone. # cron_timezone can only accept timezones listed in TZInfo::Timezone.
# Aliases of Timezones from ActiveSupport::TimeZone are NOT accepted, # Aliases of Timezones from ActiveSupport::TimeZone are NOT accepted,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment