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 milestones or 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:
- LabelReferenceFilter#references_in encounters label ~X for ProjectA and finds the label in the DB as id = 1.
- LabelReferenceFilter.references_in yields [1, 'X', nil, ...]
- Since project_ref is nil, AbstractReferenceFilter#project_from_ref_cache caches nil => ProjectA.
- LabelReferenceFilter#references_in encounters label ~Y for ProjectB and finds the label in the DB as id = 2.
- LabelReferenceFilter.references_in yields [2, 'Y', nil, ...]
- AbstractReferenceFilter#project_from_ref_cache lookups nil and returns ProjectA. It was supposed to be ProjectB.
- A is the wrong project, so the label lookup fails.
This MR expands the
project_ref to the right value as soon as we have it to avoid this caching bug.
Closes #17898 (closed)