Respond with 404 instead of 500 when requesting a wiki diff with invalid versions (#12434).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10877 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-11-24 12:27:00 +00:00
parent 845d7bc645
commit 29fc292b18
2 changed files with 17 additions and 1 deletions
+2 -1
View File
@@ -112,7 +112,8 @@ class WikiPage < ActiveRecord::Base
def diff(version_to=nil, version_from=nil)
version_to = version_to ? version_to.to_i : self.content.version
content_to = content.versions.find_by_version(version_to)
content_from = version_from ? content.versions.find_by_version(version_from.to_i) : content_to.previous
content_from = version_from ? content.versions.find_by_version(version_from.to_i) : content_to.try(:previous)
return nil unless content_to && content_from
if content_from.version > content_to.version
content_to, content_from = content_from, content_to