changeset 5467:db8b17d3a967

Fixed MoinMoinBugs/1.9DiffActionThrowsException (details see below) handle the case when we do not find both editlog entries for the diffed revs: * page does not exist at all (and never did) * one or both revs have no editlog entry * because those revs never existed * because editlog is damaged add logging delay start of content output, so we can use theme.add_msg before
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 26 Jan 2010 05:03:40 +0100
parents 9b85f7601772
children be7c57d8e2a3
files MoinMoin/action/diff.py
diffstat 1 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/diff.py	Wed Jan 20 16:04:29 2010 +0100
+++ b/MoinMoin/action/diff.py	Tue Jan 26 05:03:40 2010 +0100
@@ -8,6 +8,9 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+from MoinMoin import log
+logging = log.getLogger(__name__)
+
 from MoinMoin import wikiutil
 from MoinMoin.logfile import editlog
 from MoinMoin.Page import Page
@@ -68,12 +71,6 @@
             rev1 = 1
         rev2 = 0
 
-    # Start output
-    # This action generates content in the user language
-    request.setContentLanguage(request.lang)
-
-    request.theme.send_title(_('Diff for "%s"') % (pagename, ), pagename=pagename, allow_doubleclick=1)
-
     if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
         rev1, rev2 = rev2, rev1
 
@@ -94,8 +91,24 @@
         newrev = rev2
         newpage = Page(request, pagename, rev=newrev)
 
+    oldlog = oldpage.editlog_entry()
+    newlog = newpage.editlog_entry()
+
+    if not oldlog or not newlog:
+        # We use "No log entries found." msg because we already have i18n
+        # for that. Better would "At least one log entry was not found.".
+        request.theme.add_msg(_("No log entries found."), "error")
+        currentpage.send_page()
+        return
+
     edit_count = abs(newrev - oldrev)
 
+    # Start output
+    # This action generates content in the user language
+    request.setContentLanguage(request.lang)
+
+    request.theme.send_title(_('Diff for "%s"') % (pagename, ), pagename=pagename, allow_doubleclick=1)
+
     f = request.formatter
     request.write(f.div(1, id="content"))
 
@@ -163,9 +176,6 @@
 
     request.write(f.rawHTML(navigation_html))
 
-    oldlog = oldpage.editlog_entry()
-    newlog = newpage.editlog_entry()
-
     def rev_nav_link(enabled, old_rev, new_rev, caption, css_classes, enabled_title, disabled_title):
         if enabled:
             return currentpage.link_to(request, on=1, querystr={