Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10041 closed defect (wontfix)

[PATCH] Wrong timestamp conversion for DeleteChanges

Reported by: Boris Savelev Owned by: Ryan J Ollos
Priority: normal Component: TicketDeletePlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12


using to_timestamp is wrong

DB stores full timestamps and we must use to_utimestamp

---   (revision 11587)
+++   (working copy)
@@ -13,7 +13,7 @@
 from import ITemplateProvider
 from trac.ticket.web_ui import TicketModule 
 from trac.util import sorted
-from trac.util.datefmt import to_datetime, utc, to_timestamp
+from trac.util.datefmt import to_datetime, utc, to_timestamp, format_datetime, to_utimestamp
 import re
 import traceback
@@ -102,7 +102,7 @@
                     ticket_data = {}
                     for time, author, field, oldvalue, newvalue, perm in t.get_changelog():
-                        c_data = ticket_data.setdefault(to_timestamp(time), {})
+                        c_data = ticket_data.setdefault(to_utimestamp(time), {})
                         c_data.setdefault('fields', {})[field] = {'old': oldvalue, 'new': newvalue}
                         c_data['author'] = author
                         # FIXME: The datetime handling is not working - enable
@@ -198,7 +198,7 @@
                 cursor.execute("DELETE FROM attachment WHERE type = 'ticket' AND id = %s AND time = %s", (id, ts))
                 custom_fields = [f['name'] for f in ticket.fields if f.get('custom')]
-                if field != "comment" and not [1 for time, author, field2, oldval, newval, _ in ticket.get_changelog() if to_timestamp(time) > int(ts) and field == field2]:
+                if field != "comment" and not [1 for time, author, field2, oldval, newval, _ in ticket.get_changelog() if to_utimestamp(time) > int(ts) and field == field2]:
                     oldval = [old for _, _, field2, old, _, _ in ticket.get_changelog(to_datetime(int(ts))) if field2 == field][0]
                     if field in custom_fields:
                         cursor.execute("UPDATE ticket_custom SET value=%s WHERE ticket=%s AND name=%s", (oldval, id, field))

Attachments (0)

Change History (3)

comment:1 Changed 12 years ago by Ryan J Ollos

Owner: changed from Noah Kantrowitz to Ryan J Ollos
Status: newassigned

That is true, with Trac 0.12, you must use to_utimestamp, but did you see the message on the project wiki page? This plugin is no longer need with Trac 0.12. Just enable tracopt.ticket.deleter.

comment:2 Changed 12 years ago by Ryan J Ollos

Resolution: wontfix
Status: assignedclosed

comment:3 Changed 12 years ago by anonymous

oh. ok, sorry)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.