From 62d7f321cee50fd6bcf3a6ee0fdeefc5f2de81c5 Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Sat, 29 Dec 2018 18:12:09 +0100 Subject: [PATCH] problem fixed for migration from redmine 3.x to redmine 4 --- CHANGELOG.rst | 1 + lib/additionals.rb | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2c069aaa..e5f9206e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Changelog - Performance improvement (#36) - FontAwesome 5.6.3 support +- Fix problem from migrating from Redmine 3.x to Redmine 4 with lost settings 2.0.17 ++++++ diff --git a/lib/additionals.rb b/lib/additionals.rb index df4a205d..1f4e40c7 100644 --- a/lib/additionals.rb +++ b/lib/additionals.rb @@ -56,10 +56,18 @@ module Additionals end def settings - if Rails.version >= '5.2' - Setting[:plugin_additionals] + if Setting[:plugin_additionals].class == Hash + if Rails.version >= '5.2' + # convert Rails 4 data + new_settings = ActiveSupport::HashWithIndifferentAccess.new(Setting[:plugin_additionals]) + Setting.plugin_additionals = new_settings + new_settings + else + ActionController::Parameters.new(Setting[:plugin_additionals]) + end else - ActionController::Parameters.new(Setting[:plugin_additionals]) + # Rails 5 uses ActiveSupport::HashWithIndifferentAccess + Setting[:plugin_additionals] end end