プロジェクト

全般

プロフィール

Vote #80839

完了

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

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Administration_8
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
8
version_id:
162
issue_org_id:
33355
author_id:
332
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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

journals

I've attached a patch to fix the problem.
--------------------------------------------------------------------------------
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.

<pre><code class="diff">
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 %>
</code></pre>
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Here is a patch based on #33355#note-2.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Setting the target version to 4.1.2.
--------------------------------------------------------------------------------
Committed the patch.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,5899,Display user's gravatar when editing profile

Admin Redmine さんが4年以上前に更新

  • カテゴリAdministration_8 にセット
  • 対象バージョン4.1.2_162 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0