Modify

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#10041 closed defect (wontfix)

[PATCH] Wrong timestamp conversion for DeleteChanges

Reported by: bsavelev Owned by: rjollos
Priority: normal Component: TicketDeletePlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

using to_timestamp is wrong

DB stores full timestamps and we must use to_utimestamp

Index: web_ui.py
===================================================================
--- web_ui.py   (revision 11587)
+++ web_ui.py   (working copy)
@@ -13,7 +13,7 @@
 from trac.web.chrome 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))
             else:
                 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 2 years ago by rjollos

  • Owner changed from coderanger to rjollos
  • Status changed from new to assigned

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 2 years ago by rjollos

  • Resolution set to wontfix
  • Status changed from assigned to closed

comment:3 Changed 2 years ago by anonymous

oh. ok, sorry)

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from rjollos. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.