プロジェクト

全般

プロフィール

Vote #78306

完了

Adding a principal to 2 projects with member inheritance leads to an error

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

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

0%

予定工数:
category_id:
8
version_id:
119
issue_org_id:
25289
author_id:
3866
assigned_to_id:
1
comments:
3
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

When batch adding a user or a group to a project through the projects tab of the user/group page, adding the a user or group to 2 projects where one project inherits its members from the other might lead to an error (depending on the order of the projects, the parent project must come before the child project for this to happen, which it should as in the batch add view projects are arranged in trees). If more than those 2 projects are involved in the batch addition to a project, the user or group won't be added to all projects that come after the child project as the processing stops on the error.

This happens in source:/trunk/app/models/member.rb@16379#L175: First all @Member@ s are created, then they are saved in the @principal.members << members@ line. Saving the @Member@ object for a parent project with a child project inheriting its members will create a @Member@ object for the child project too, which then leads to an error when the @Member@ error created for that child project is saved and recognised as a duplicate.


journals

The attached patch solves this problem. No test though as this method is currently untested, we can provide tests too if required.

The patch saves each new @Member@ directly in the loop instead of saving all in one go at the end of the loop. Please note that this does not significantly affect performance as @principal.members << members@ still saves each @Member@ one at a time. This allows the loop to recognise if a previous iteration already created a @Member@ we are trying to instantiate and avoids the clash described above.

Please note that roles are added to the @Member@ instead of destructively replacing already present roles. This would also allow changing the "Add project" modal of groups/users from being able to only add the group/user to projects it is not already a member of to adding the user/group with the selected role to any project in addition to already existing role/project combinations for that user/group.
--------------------------------------------------------------------------------
Patch committed, thanks for catching this issue. I've added a test for this.
--------------------------------------------------------------------------------
Looks great, thanks!
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

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

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

いいね!0
いいね!0