settings supports migration from redmine 3.x to redmine 4

This commit is contained in:
Alexander Meindl
2018-12-29 21:38:05 +01:00
parent 23673170b4
commit 1d7e53fd9c

View File

@@ -6,10 +6,18 @@ Rails.configuration.to_prepare do
REDMINE_PASSWORDS_SUPPORT = Redmine::Plugin.installed?('redmine_passwords') ? true : false
def self.settings
if Rails.version >= '5.2'
Setting[:plugin_redmine_messenger]
if Setting[:plugin_redmine_messenger].class == Hash
if Rails.version >= '5.2'
# convert Rails 4 data
new_settings = ActiveSupport::HashWithIndifferentAccess.new(Setting[:plugin_redmine_messenger])
Setting.plugin_redmine_messenger = new_settings
new_settings
else
ActionController::Parameters.new(Setting[:plugin_redmine_messenger])
end
else
ActionController::Parameters.new(Setting[:plugin_redmine_messenger])
# Rails 5 uses ActiveSupport::HashWithIndifferentAccess
Setting[:plugin_redmine_messenger]
end
end