Commit dc016fef3983a956bb3f98a70b8db6490e949605
1 parent
c8e3d319
Exists in
master
and in
4 other branches
Add redirect from Issue#id to Issue#iid
Showing
1 changed file
with
21 additions
and
1 deletions
Show diff stats
app/controllers/projects/issues_controller.rb
... | ... | @@ -91,7 +91,11 @@ class Projects::IssuesController < Projects::ApplicationController |
91 | 91 | protected |
92 | 92 | |
93 | 93 | def issue |
94 | - @issue ||= @project.issues.find_by_iid!(params[:id]) | |
94 | + @issue ||= begin | |
95 | + @project.issues.find_by_iid!(params[:id]) | |
96 | + rescue ActiveRecord::RecordNotFound | |
97 | + redirect_old | |
98 | + end | |
95 | 99 | end |
96 | 100 | |
97 | 101 | def authorize_modify_issue! |
... | ... | @@ -109,4 +113,20 @@ class Projects::IssuesController < Projects::ApplicationController |
109 | 113 | def issues_filtered |
110 | 114 | @issues = Issues::ListContext.new(project, current_user, params).execute |
111 | 115 | end |
116 | + | |
117 | + # Since iids are implemented only in 6.1 | |
118 | + # user may navigate to issue page using old global ids. | |
119 | + # | |
120 | + # To prevent 404 errors we provide a redirect to correct iids until 7.0 release | |
121 | + # | |
122 | + def redirect_old | |
123 | + issue = @project.issues.find_by_id(params[:id]) | |
124 | + | |
125 | + if issue | |
126 | + redirect_to project_issue_path(@project, issue) | |
127 | + return | |
128 | + else | |
129 | + raise ActiveRecord::RecordNotFound.new | |
130 | + end | |
131 | + end | |
112 | 132 | end | ... | ... |