diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-08-26 14:15:21 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-08-26 14:15:21 +0300 |
commit | dc016fef3983a956bb3f98a70b8db6490e949605 (patch) | |
tree | 24ba0a87d7a88a97ea587b992e83c4b2bd684d2a /app/controllers | |
parent | c8e3d3192532839b7648301eb0849fd76da4f04b (diff) | |
download | gitlab-ce-dc016fef3983a956bb3f98a70b8db6490e949605.tar.gz |
Add redirect from Issue#id to Issue#iid
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 4b6e22e3607..e8f845b2d17 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -91,7 +91,11 @@ class Projects::IssuesController < Projects::ApplicationController protected def issue - @issue ||= @project.issues.find_by_iid!(params[:id]) + @issue ||= begin + @project.issues.find_by_iid!(params[:id]) + rescue ActiveRecord::RecordNotFound + redirect_old + end end def authorize_modify_issue! @@ -109,4 +113,20 @@ class Projects::IssuesController < Projects::ApplicationController def issues_filtered @issues = Issues::ListContext.new(project, current_user, params).execute end + + # Since iids are implemented only in 6.1 + # user may navigate to issue page using old global ids. + # + # To prevent 404 errors we provide a redirect to correct iids until 7.0 release + # + def redirect_old + issue = @project.issues.find_by_id(params[:id]) + + if issue + redirect_to project_issue_path(@project, issue) + return + else + raise ActiveRecord::RecordNotFound.new + end + end end |