Fix 404 page when viewing TODOs that contain milestones or labels in different projects
A user viewing the TODOs page will see a 404 if there are mentioned labels in multiple different projects. This is likely a caching bug and only occurs when Markdown rendering occurs across multiple projects, which is why it's so tricky to reproduce. This is what I think is happening: 1. LabelReferenceFilter#references_in encounters label ~X for ProjectA and finds the label in the DB as id = 1. 2. LabelReferenceFilter.references_in yields [1, 'X', nil, ...] 3. Since project_ref is nil, AbstractReferenceFilter#project_from_ref_cache caches nil => ProjectA. 4. LabelReferenceFilter#references_in encounters label ~Y for ProjectB and finds the label in the DB as id = 2. 5. LabelReferenceFilter.references_in yields [2, 'Y', nil, ...] 6. AbstractReferenceFilter#project_from_ref_cache lookups nil and returns ProjectA. It was supposed to be ProjectB. 7. A is the wrong project, so the label lookup fails. This MR caches Markdown references if the key is present. Closes #17898
This commit is contained in:
parent
473ea1e974
commit
f8a3344d12
|
@ -6,6 +6,7 @@ v 8.9.0 (unreleased)
|
||||||
- Allow forking projects with restricted visibility level
|
- Allow forking projects with restricted visibility level
|
||||||
- Improve note validation to prevent errors when creating invalid note via API
|
- Improve note validation to prevent errors when creating invalid note via API
|
||||||
- Remove project notification settings associated with deleted projects
|
- Remove project notification settings associated with deleted projects
|
||||||
|
- Fix 404 page when viewing TODOs that contain milestones or labels in different projects
|
||||||
- Redesign navigation for project pages
|
- Redesign navigation for project pages
|
||||||
- Fix groups API to list only user's accessible projects
|
- Fix groups API to list only user's accessible projects
|
||||||
- Redesign account and email confirmation emails
|
- Redesign account and email confirmation emails
|
||||||
|
|
|
@ -236,7 +236,9 @@ module Banzai
|
||||||
if cache.key?(key)
|
if cache.key?(key)
|
||||||
cache[key]
|
cache[key]
|
||||||
else
|
else
|
||||||
cache[key] = yield
|
value = yield
|
||||||
|
cache[key] = value if key.present?
|
||||||
|
value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,6 +43,27 @@ describe 'Dashboard Todos', feature: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'User has Todos with labels spanning multiple projects' do
|
||||||
|
before do
|
||||||
|
label1 = create(:label, project: project)
|
||||||
|
note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project)
|
||||||
|
create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id)
|
||||||
|
|
||||||
|
project2 = create(:project)
|
||||||
|
label2 = create(:label, project: project2)
|
||||||
|
issue2 = create(:issue, project: project2)
|
||||||
|
note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2)
|
||||||
|
create(:todo, :mentioned, project: project2, target: issue2, user: user, note_id: note2.id)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit dashboard_todos_path
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows page with two Todos' do
|
||||||
|
expect(page).to have_selector('.todos-list .todo', count: 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'User has multiple pages of Todos' do
|
context 'User has multiple pages of Todos' do
|
||||||
before do
|
before do
|
||||||
allow(Todo).to receive(:default_per_page).and_return(1)
|
allow(Todo).to receive(:default_per_page).and_return(1)
|
||||||
|
|
Loading…
Reference in New Issue