diff options
author | Nick Thomas <nick@gitlab.com> | 2018-10-15 22:07:02 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-10-17 15:24:52 +0300 |
commit | d66066f7cb4a2981c74224ad2cb6ec3c00ca529e (patch) | |
tree | e416f31d864631ad9b231870eb8bae46d2234aac /app/models/wiki_page.rb | |
parent | e657c9a9e6d9877a4bf0b3fb39a0f4bff0dc5470 (diff) |
Harden the wiki against missing last_versions
Currently, we assume a "last_version" always exists for a wiki page.
In production, this is not always true. So, guard uses of it with a
null check.
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 42fd213d03b..c5e349ae913 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -160,7 +160,9 @@ class WikiPage # Returns boolean True or False if this instance # is an old version of the page. def historical? - @page.historical? && last_version.sha != version.sha + return false unless last_commit_sha && version + + @page.historical? && last_commit_sha != version.sha end # Returns boolean True or False if this instance |