Defect #33183

Unable to edit user or group that has custom fields with text formatting enabled

Added by Go MAEDA 5 months ago. Updated 5 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Custom fields
Target version:4.1.1
Resolution:Fixed Affected version:4.1.0

Description

Steps to reproduce:

1. Add a text format UserCustomField
2. Enable "Text formatting" for the custom field
3. Try to edit any user. You will see the Internal Server Error page

Completed 500 Internal Server Error in 145ms (ActiveRecord: 4.4ms)

ActionView::Template::Error (undefined method `project' for #<User:0x00007fafaefe19a0>
Did you mean?  projects
               projects=):
    18:   <% end %>
    19: 
    20:   <% @user.custom_field_values.each do |value| %>
    21:     <p><%= custom_field_tag_with_label :user, value %></p>
    22:   <% end %>
    23: 
    24:   <p><%= f.check_box :admin, :disabled => (@user == User.current) %></p>

app/helpers/custom_fields_helper.rb:89:in `custom_field_tag'
app/helpers/custom_fields_helper.rb:120:in `custom_field_tag_with_label'
app/views/users/_form.html.erb:21:in `block in _app_views_users__form_html_erb__1594929617543875487_70196358321500'
app/views/users/_form.html.erb:20:in `each'
app/views/users/_form.html.erb:20:in `_app_views_users__form_html_erb__1594929617543875487_70196358321500'
app/views/users/_general.html.erb:2:in `block in _app_views_users__general_html_erb___1757341575386637995_70196280622620'
app/helpers/application_helper.rb:1381:in `labelled_form_for'
app/views/users/_general.html.erb:1:in `_app_views_users__general_html_erb___1757341575386637995_70196280622620'
app/views/common/_tabs.html.erb:21:in `block in _app_views_common__tabs_html_erb__1281727382652852600_70196280567080'
app/views/common/_tabs.html.erb:20:in `each'
app/views/common/_tabs.html.erb:20:in `_app_views_common__tabs_html_erb__1281727382652852600_70196280567080'
app/helpers/application_helper.rb:457:in `render_tabs'
app/views/users/edit.html.erb:13:in `_app_views_users_edit_html_erb___3120376360499099218_70196265966740'
lib/redmine/sudo_mode.rb:64:in `sudo_mode'

test_for_33183.patch Magnifier (669 Bytes) Marius BALTEANU, 2020-03-23 18:23


Related issues

Related to Redmine - Feature #31989: Inline issue auto complete (#) in fields with text-format... Closed

Associated revisions

Revision 19613
Added by Go MAEDA 5 months ago

Unable to edit user or group that has custom fields with text formatting enabled (#33183).

Patch by Go MAEDA and Marius BALTEANU.

Revision 19614
Added by Go MAEDA 5 months ago

Merged r19613 from trunk to 4.1-stable (#33183).

History

#1 Updated by Go MAEDA 5 months ago

This is due to r18444.

#2 Updated by Go MAEDA 5 months ago

  • Related to Feature #31989: Inline issue auto complete (#) in fields with text-formatting enabled added

#3 Updated by Marius BALTEANU 5 months ago

  • Assignee set to Marius BALTEANU

#4 Updated by Go MAEDA 5 months ago

The following code fixes the issue.

diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index a6fbff9bd..26023ae94 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -86,7 +86,7 @@ module CustomFieldsHelper
       data = {
         :auto_complete => true,
         :issues_url => auto_complete_issues_path(:project_id => custom_value.customized.project, :q => '')
-      } if custom_value.customized && custom_value.customized.project
+      } if custom_value.customized && custom_value.customized.try(:project)
     end
     custom_value.custom_field.format.edit_tag(
       self,

#5 Updated by Marius BALTEANU 5 months ago

  • File test_for_33183.patchMagnifier added
  • Assignee changed from Marius BALTEANU to Go MAEDA
  • Target version set to 4.1.1

The fix looks good to me and I have attached a test case.

Thanks Go Maeda for detecting this issue.

#6 Updated by Go MAEDA 5 months ago

  • Subject changed from Cannot edit user if it has UserCustomField with text_formatting enabled to Unable to edit user or group that has custom fields with text formatting enabled
  • Status changed from New to Closed
  • Resolution set to Fixed

Committed the patch.

Also available in: Atom PDF