Defect #17217
openError when you try to config issue checklist plugin with empty checkboxes
0%
Description
Environment info:
Environment:
Redmine version 2.5.1.stable
Ruby version 2.0.0-p481 (2014-05-08) [x86_64-linux]
Rails version 3.2.17
Environment production
Database adapter Mysql2
Mysql version 5.5.37-0ubuntu0.14.04.1 (Ubuntu)
SCM:
Subversion 1.8.8
Git 1.9.1
Filesystem
Redmine plugins:
redmine_agile 1.3.1
redmine_ics_export 2.0.0.dev
redmine_issue_checklist 2.0.5
redmine_omniauth_google 0.0.1
redmine_timesheet_plugin 0.7.0
Bug description:
when you go to checklist plugin config page (/settings/plugin/redmine_issue_checklist) and you unselect all the checkboxes and save, an internal error is shown on the screen. The error log message is attached as error_redmine_issue_checklist.txt
The problem consisted of the serialization of an all false options hash into a database column. the all false options hash, serialized into "", was returned to @settings in SettingsController as a "" string insted of an empty hash {}.
It affects all plugins with more than one config option (options are serialized).
Bug solution:
in SettingsControler#plugin I added 2 lines of code that fixes the bug
def plugin
@plugin = Redmine::Plugin.find(params[:id])
unless @plugin.configurable?
render_404
return
end
if request.post?
Setting.send "plugin_#{@plugin.id}=", params[:settings]
flash[:notice] = l(:notice_successful_update)
redirect_to plugin_settings_path(@plugin)
else
@partial = @plugin.settings[:partial]
@settings = Setting.send "plugin_#{@plugin.id}"
settings_options = Setting.available_settings["plugin_#{@plugin.id}"] || {}
@settings = {} if @settings == "" && settings_options["serialized"]
end
rescue Redmine::PluginNotFound
render_404
end
I attach the controller app/controllers/settings_controller.rb file.
Files