プロジェクト

全般

プロフィール

Vote #78974

完了

Same relates relation can be created twice

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

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

0%

予定工数:
category_id:
2
version_id:
136
issue_org_id:
27663
author_id:
14446
assigned_to_id:
332
comments:
7
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

By switching from and to, it is possible to create the same relates relation twice. Within the Redmine UI, those relations look like duplicates.

For all other relationship types it's not allowed to create duplicates, so I assume that this is a bug. Attached you may find a proposed fix. It adds a validation to make sure, that reverse relations are detected. It also orders the from and to IDs to ensure, that even during concurrent access, the duplicates are detected on DB level.


journals

I confirmed the problem.

!{width: 718px; border: 1px solid #ccc;}.duplicated-related-issue@2x.png!

<pre>
sqlite> select * from issue_relations where issue_from_id in (42, 43);
id issue_from_id issue_to_id relation_type delay
---------- ------------- ----------- ------------- ----------
5 42 43 relates
4 43 42 relates
</pre>
--------------------------------------------------------------------------------
LGTM. Setting target version to 3.3.6.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
The patch breaks a test.

<pre>
$ bin/rails test test/functional/issue_relations_controller_test.rb
Run options: --seed 33551

# Running:

...F

Failure:
IssueRelationsControllerTest#test_create_xhr [/Users/maeda/redmines/redmine-trunk/test/functional/issue_relations_controller_test.rb:85]:
Expected: 3
Actual: 1

bin/rails test test/functional/issue_relations_controller_test.rb:70

........

Finished in 4.495535s, 2.6693 runs/s, 6.6733 assertions/s.
12 runs, 30 assertions, 1 failures, 0 errors, 0 skips
</pre>
--------------------------------------------------------------------------------
Fix for the test failure described in #27663#note-4.
@issue_from_id@ is always smaller than @issue_to_id@ after applying the patch.

<pre><code class="diff">
Index: test/functional/issue_relations_controller_test.rb
===================================================================
--- test/functional/issue_relations_controller_test.rb (revision 17054)
+++ test/functional/issue_relations_controller_test.rb (working copy)
@@ -82,8 +82,8 @@
assert_equal 'text/javascript', response.content_type
end
relation = IssueRelation.order('id DESC').first
- assert_equal 3, relation.issue_from_id
- assert_equal 1, relation.issue_to_id
+ assert_equal 1, relation.issue_from_id
+ assert_equal 3, relation.issue_to_id

assert_include 'Bug #1', response.body
end
</code></pre>
--------------------------------------------------------------------------------
Committed in the trunk and merged to stable branches. Thank you.
--------------------------------------------------------------------------------
Thanks a lot.

I am very sorry for breaking the test suite. I hope this did not cause too much trouble. I'll make sure to run the whole test suite next time.
--------------------------------------------------------------------------------

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

  • カテゴリIssues_2 にセット
  • 対象バージョン3.3.6_136 にセット

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

いいね!0
いいね!0