diff options
| author | Stan Hu <stanhu@gmail.com> | 2016-05-26 20:37:41 -0700 |
|---|---|---|
| committer | Stan Hu <stanhu@gmail.com> | 2016-05-31 20:37:53 -0700 |
| commit | f8a3344d1297e2a66d1ec60372258c651c74baf5 (patch) | |
| tree | d5f677ac070513f9c03feb5ba6b64bc06398a1cb /lib/banzai | |
| parent | 473ea1e974cf07751601904b882de9ee2b3d0618 (diff) | |
| download | gitlab-ce-f8a3344d1297e2a66d1ec60372258c651c74baf5.tar.gz | |
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
Diffstat (limited to 'lib/banzai')
| -rw-r--r-- | lib/banzai/filter/abstract_reference_filter.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb index b8962379cb5..65283fe96a4 100644 --- a/lib/banzai/filter/abstract_reference_filter.rb +++ b/lib/banzai/filter/abstract_reference_filter.rb @@ -236,7 +236,9 @@ module Banzai if cache.key?(key) cache[key] else - cache[key] = yield + value = yield + cache[key] = value if key.present? + value end end end |
