changeset 2218:c391df32467f

fixed crash of xapian AdvancedSearch (fullsearch action) if mtime string is invalid, e.g. '2 days'
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 26 May 2007 18:28:07 +0200
parents f8dcc3232e8b
children dc5cd1a4b397
files MoinMoin/action/fullsearch.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/fullsearch.py	Sat May 26 17:39:21 2007 +0200
+++ b/MoinMoin/action/fullsearch.py	Sat May 26 18:28:07 2007 +0200
@@ -118,13 +118,19 @@
             else:
                 # didn't work, let's try parsedatetime
                 cal = Calendar()
-                mtime_parsed = cal.parse(mtime)
-
-                if mtime_parsed[1] == 0 and mtime_parsed[0] <= time.localtime():
-                    mtime = time.mktime(mtime_parsed[0])
+                mtime_parsed, invalid_flag = cal.parse(mtime)
+                # XXX it is unclear if usage of localtime here and in parsedatetime module is correct.
+                # time.localtime is the SERVER's local time and of no relevance to the user (being
+                # somewhere in the world)
+                # mktime is reverse function for localtime, so this maybe fixes it again!?
+                if not invalid_flag and mtime_parsed <= time.localtime():
+                    mtime = time.mktime(mtime_parsed)
+                else:
+                    mtime_parsed = None # we don't use invalid stuff
 
             # show info
             if mtime_parsed:
+                # XXX mtime_msg is not shown in some cases
                 mtime_msg = _("(!) Only pages changed since '''%s''' are being "
                         "displayed!") % request.user.getFormattedDateTime(mtime)
             else: