Defect #16038

Issue#css_classes corrupts user.groups association cache

Added by Toshi MARUYAMA about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Code cleanup/refactoring
Target version:2.4.3
Resolution:Fixed Affected version:

Description

https://github.com/redmine/redmine/pull/27

diff --git a/app/models/issue.rb b/app/models/issue.rb
index debb931..b9a2b20 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1091,7 +1091,7 @@ def css_classes(user=User.current)
     if user.logged?
       s << ' created-by-me' if author_id == user.id
       s << ' assigned-to-me' if assigned_to_id == user.id
-      s << ' assigned-to-my-group' if user.groups.any? {|g| g.id = assigned_to_id}
+      s << ' assigned-to-my-group' if user.groups.any? {|g| g.id == assigned_to_id}
     end
     s
   end

If user belongs any groups, 'assigned-to-my-group' is set.
It is wrong.


Related issues

Related to Redmine - Defect #12681: Treat group assignments as assigned to me Closed
Related to Redmine - Defect #16166: Incorrect data on Issues assigned to me on MyPage Closed
Duplicates Redmine - Patch #16002: Assigned-to-my-group css corrupts user.groups association... Closed

Associated revisions

Revision 12844
Added by Toshi MARUYAMA about 4 years ago

fix wrong issue 'assigned-to-my-group' css class (#16038)

History

#1 Updated by Toshi MARUYAMA about 4 years ago

  • Related to Defect #12681: Treat group assignments as assigned to me added

#2 Updated by Toshi MARUYAMA about 4 years ago

  • Category set to UI

#3 Updated by Toshi MARUYAMA about 4 years ago

  • Private changed from No to Yes

#4 Updated by Toshi MARUYAMA about 4 years ago

It has serious side effect.

1.9.3p484 :002 > user = Group.find(10).users.first
1.9.3p484 :004 > user.groups.collect(&:id)
  Group Load (1.0ms)  SELECT "users".* FROM "users" INNER JOIN "groups_users" ON "users"."id" = "groups_users"."group_id" WHERE "users"."type" IN ('Group') AND "groups_users"."user_id" = 8
 => [10, 11] 
1.9.3p484 :005 > assigned_to_id = 1
 => 1 
1.9.3p484 :006 > user.groups.any? {|g| g.id == assigned_to_id}
 => false 
1.9.3p484 :007 > user.groups.any? {|g| g.id = assigned_to_id}
 => true 
1.9.3p484 :008 > user.groups.collect(&:id)
 => [1, 11] 

#5 Updated by Toshi MARUYAMA about 4 years ago

But, it seems no effect on database.

1.9.3p484 :011 > user.save!
   (0.3ms)  begin transaction
   (0.2ms)  commit transaction
 => true 
1.9.3p484 :012 > user.groups.collect(&:id)
 => [1, 11] 
1.9.3p484 :013 > user.reload
  User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('User', 'AnonymousUser') AND "users"."id" = ? LIMIT 1  [["id", 8]]
 => #<User id: 8, login: "miscuser8", hashed_password: "8f659c8d7c072f189374edacfa90d6abbc26d8ed", firstname: "User", lastname: "Misc", mail: "miscuser8@foo.bar", admin: false, status: 1, last_login_on: nil, language: "it", auth_source_id: nil, created_on: "2006-07-19 17:33:19", updated_on: "2006-07-19 17:33:19", type: "User", identity_url: nil, mail_notification: "only_my_events", salt: "7599f9963ec07b5a3b55b354407120c0", must_change_passwd: false> 
1.9.3p484 :014 > user.groups.collect(&:id)
  Group Load (0.5ms)  SELECT "users".* FROM "users" INNER JOIN "groups_users" ON "users"."id" = "groups_users"."group_id" WHERE "users"."type" IN ('Group') AND "groups_users"."user_id" = 8
 => [10, 11] 

#6 Updated by Jean-Philippe Lang about 4 years ago

  • Duplicates Patch #16002: Assigned-to-my-group css corrupts user.groups association cache added

#7 Updated by Jean-Philippe Lang about 4 years ago

  • Subject changed from Issue 'assigned-to-my-group' css class is wrong to Issue#css_classes corrupts user.groups association cache
  • Category changed from UI to Code cleanup/refactoring
  • Status changed from New to Closed
  • Private changed from Yes to No
  • Resolution set to Fixed

#8 Updated by Jean-Philippe Lang about 4 years ago

  • Related to Defect #16166: Incorrect data on Issues assigned to me on MyPage added

Also available in: Atom PDF