diff options
author | Stan Hu <stanhu@gmail.com> | 2019-06-08 08:54:51 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-06-10 09:53:49 +0300 |
commit | 1a4d1b05012bad8a9624ed52ea563a2d54a77716 (patch) | |
tree | a3e6c6d48521d5697230d7f4c223c777ccdbd6af /app | |
parent | 3017d2a52a3da5dc8e701f442b6d7c65c19cc054 (diff) |
Fix Fogbugz Importer not working
This stopped working in GitLab 11.11 when we upgraded to Rails 5.1.
Rails 5 changed ActionController::Parameters to return an Object instead
of a Hash. The old behavior was deprecated in Rails 5 but finally
removed in Rails 5.1
Since the controller wasn't updated properly, the callback endpoint
quietly failed with the message, "Could not connect to FogBugz, check
your url".
To fix this, we need to call `to_h` on the `import_params` to access the
Hash. We also need to do this for the user map and permit specific keys.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/33530
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/import/fogbugz_controller.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/import/fogbugz_controller.rb b/app/controllers/import/fogbugz_controller.rb index a37ba682b91..28ead8d44da 100644 --- a/app/controllers/import/fogbugz_controller.rb +++ b/app/controllers/import/fogbugz_controller.rb @@ -11,7 +11,7 @@ class Import::FogbugzController < Import::BaseController def callback begin - res = Gitlab::FogbugzImport::Client.new(import_params.symbolize_keys) + res = Gitlab::FogbugzImport::Client.new(import_params.to_h.symbolize_keys) rescue # If the URI is invalid various errors can occur return redirect_to new_import_fogbugz_path, alert: _('Could not connect to FogBugz, check your URL') @@ -26,7 +26,7 @@ class Import::FogbugzController < Import::BaseController end def create_user_map - user_map = params[:users] + user_map = user_map_params.to_h[:users] unless user_map.is_a?(Hash) && user_map.all? { |k, v| !v[:name].blank? } flash.now[:alert] = _('All users must have a name.') @@ -99,6 +99,10 @@ class Import::FogbugzController < Import::BaseController params.permit(:uri, :email, :password) end + def user_map_params + params.permit(users: %w(name email gitlab_user)) + end + def verify_fogbugz_import_enabled render_404 unless fogbugz_import_enabled? end |