Defect #33355

TypeError when attempting to update a user with a blank email address

Added by Go MAEDA 12 months ago. Updated 4 months ago.

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

0%

Category:Administration
Target version:4.1.2
Resolution: Affected version:

Description

Started PATCH "/users/3" for 127.0.0.1 at 2020-04-26 16:42:34 +0900
Processing by UsersController#update as HTML
.
.
.
ActionView::Template::Error (no implicit conversion of nil into String):
     7:
     8: <%=
     9:   page_title = title [l(:label_user_plural), users_path], @user.login
    10:   page_title.insert(page_title.rindex(' ') + 1, avatar(@user))
    11: %>
    12:
    13: <%= render_tabs user_settings_tabs %>

app/views/users/edit.html.erb:10:in `insert'
app/views/users/edit.html.erb:10:in `_app_views_users_edit_html_erb___718898119020271380_70199616790460'
app/controllers/users_controller.rb:180:in `block (2 levels) in update'
app/controllers/users_controller.rb:179:in `update'
lib/redmine/sudo_mode.rb:64:in `sudo_mode'

Steps to reproduce:
1. Enable "Use Gravatar user icons" (Setting.gravatar_enabled)
2. Update any user with a blank email address from the Administration page
3. "Email cannot be blank" error is expected but actually you will encounter the exception

diff.patch Magnifier (1008 Bytes) Mizuki ISHIKAWA, 2020-04-28 06:38

33355.patch Magnifier (1.23 KB) Go MAEDA, 2020-11-30 10:39


Related issues

Related to Redmine - Patch #5899: Display user's gravatar when editing profile Closed 2010-07-18

Associated revisions

Revision 20562
Added by Go MAEDA 4 months ago

TypeError when attempting to update a user with a blank email address (#33355).

Patch by Go MAEDA.

Revision 20563
Added by Go MAEDA 4 months ago

Merged r20562 from trunk to 4.1-stable (#33355).

History

#1 Updated by Mizuki ISHIKAWA 12 months ago

I've attached a patch to fix the problem.

#2 Updated by Go MAEDA 12 months ago

I'm not sure which is more appropriate, changing the API of AvatarsHelper as suggested in #note-1, or changing app/views/users/edit.html.erb as follows.

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 2a8b6707f..786630869 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -7,7 +7,7 @@

 <%=
   page_title = title [l(:label_user_plural), users_path], @user.login
-  page_title.insert(page_title.rindex(' ') + 1, avatar(@user))
+  page_title.insert(page_title.rindex(' ') + 1, avatar(@user).to_s)
 %>

 <%= render_tabs user_settings_tabs %>

#4 Updated by Mizuki ISHIKAWA 5 months ago

Go MAEDA wrote:

I'm not sure which is more appropriate, changing the API of AvatarsHelper as suggested in #note-1, or changing app/views/users/edit.html.erb as follows.

[...]

The solution you have proposed looks simpler and better.

#5 Updated by Go MAEDA 5 months ago

Here is a patch based on #33355#note-2.

#6 Updated by Go MAEDA 5 months ago

  • Target version set to Candidate for next minor release

#7 Updated by Go MAEDA 5 months ago

  • Target version changed from Candidate for next minor release to 4.1.2

Setting the target version to 4.1.2.

#8 Updated by Go MAEDA 4 months ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA

Committed the patch.

#9 Updated by Go MAEDA 4 months ago

  • Related to Patch #5899: Display user's gravatar when editing profile added

#10 Updated by Go MAEDA 4 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF