This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new e50160c83 fix for wiki pages that don't have any history
e50160c83 is described below
commit e50160c83dd3311c65e1822c2e77c71c6e6f5111
Author: Dave Brondsema <[email protected]>
AuthorDate: Thu Jan 2 15:03:21 2025 -0500
fix for wiki pages that don't have any history
---
ForgeWiki/forgewiki/tests/functional/test_root.py | 16 ++++++++++++++++
ForgeWiki/forgewiki/wiki_main.py | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py
b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 6459c853c..2d8aaef19 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -21,6 +21,8 @@ import allura
import json
import PIL
+
+from forgewiki.model import Page
from ming.odm.odmsession import ThreadLocalODMSession
from mock import patch
from tg import config
@@ -262,6 +264,20 @@ class TestRootController(TestController):
response.mustcontain('text1')
response.mustcontain(no='text2')
+ def test_page_history_missing(self):
+ self.app.get(h.urlquote('/wiki/tést/'))
+ self.app.post(
+ h.urlquote('/wiki/tést/update'),
+ params={
+ 'title': 'tést'.encode(),
+ 'text': 'text1',
+ 'labels': '',
+ })
+ for snapshot in Page.query.get(title='tést').history():
+ snapshot.delete()
+ r = self.app.get(h.urlquote('/wiki/tést/'))
+ r.mustcontain(no='There is a newer version')
+
def test_page_diff(self):
self.app.post(
h.urlquote('/wiki/tést/update'),
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 1f66a7212..a24a1df4c 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -617,7 +617,7 @@ class PageController(BaseController, FeedController):
hide_left_bar = not (c.app.show_left_bar)
subscribed_to_page = M.Mailbox.subscribed(artifact=self.page)
latest_version = self.page.history().limit(1).first()
- is_latest_version = cur == latest_version.version
+ is_latest_version = not latest_version or cur == latest_version.version
return dict(
page=page,
cur=cur, prev=prev, next=next,