Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#6490 closed defect (fixed)

Error when trying to delete priority

Reported by: jason Owned by: osimons
Priority: high Milestone: 0.11
Component: ticket system Version: devel
Severity: major Keywords:
Cc: justin@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

When trying to delete a priority via WebAdmin:

Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/api.py", line 341, in send_error
    'text/html')
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/chrome.py", line 608, in render_template
    if not req.session or not int(req.session.get('accesskeys', 0)):
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/api.py", line 170, in __getattr__
    value = self.callbacks[name](self)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/main.py", line 255, in _get_session
    return Session(self.env, req)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/session.py", line 53, in __init__
    self.get_session(req.authname, authenticated=True)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/web/session.py", line 74, in get_session
    (sid, int(authenticated)))
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.3/site-packages/Trac-0.11dev_r6319-py2.3.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: current transaction is aborted, commands ignored until end of transaction block

Attachments (0)

Change History (8)

comment:1 by Christian Boos, 16 years ago

Keywords: needinfo added
Milestone: 0.11.1

That backtrace is a secondary error while trying to send the error which occurred when deleting the priority. Any hint about what could have caused that first failure? No existing priority?

(I can't trigger an error)

comment:2 by justin@…, 16 years ago

Cc: justin@… added

I fixed it by taking out these lines in trac/ticket/model.py:

cursor.execute("UPDATE enum set value=value-1 where "

"type=%s and value>%s", (self.type, self._old_value))

Now I can delete priorities. But I can't fix the ordering to start from 1, which goofs up the coloring, as has been discussed in other tickets. I am using r6322.

in reply to:  2 ; comment:3 by osimons, 16 years ago

Component: webadminticket system
Keywords: needinfo removed
Owner: changed from Christopher Lenz to osimons

Replying to justin@jetiprinters.com:

I fixed it by taking out these lines in trac/ticket/model.py:

cursor.execute("UPDATE enum set value=value-1 where "

"type=%s and value>%s", (self.type, self._old_value))

Oops. That seems to be my change at [6317] for #2876. Worked fine on my test, but apparently it isn't stable enough. I'll look into it within the next couple of hours.

Now I can delete priorities. But I can't fix the ordering to start from 1, which goofs up the coloring, as has been discussed in other tickets. I am using r6322.

No. I have no solution for the ordering other than to clean it using sql like you want it - or delete all priorities and recreate them. That should reset the order.

in reply to:  3 ; comment:4 by jason, 16 years ago

No. I have no solution for the ordering other than to clean it using sql like you want it - or delete all priorities and recreate them. That should reset the order.

Right. If I delete and recreate all priorities, what happens to existing tickets?

in reply to:  4 comment:5 by osimons, 16 years ago

Replying to jason:

Right. If I delete and recreate all priorities, what happens to existing tickets?

They are just stored as values equal to name in tickets and ticket history. There are no foreign keys, so deleting and recreating should be a harmless operation. Do make a backup though, just to be sure.

Replying to osimons:

Oops. That seems to be my change at [6317] for #2876. Worked fine on my test, but apparently it isn't stable enough. I'll look into it within the next couple of hours.

Changed to use existing API instead of making new SQL - SQL that was obviously wrong now that I notice field is stored as text… My mistake. Could you/someone try this patch:

  • trac/ticket/model.py

     
    371371        self.env.log.info('Deleting %s %s' % (self.type, self.name))
    372372        cursor.execute("DELETE FROM enum WHERE type=%s AND value=%s",
    373373                       (self.type, self._old_value))
    374         cursor.execute("UPDATE enum set value=value-1 where "
    375                        "type=%s and value>%s", (self.type, self._old_value))
     374        # Re-order any enums that have higher value than deleted (close gaps)
     375        for enum in self.select(self.env):
     376            try:
     377                if int(enum.value) > int(self._old_value):
     378                    enum.value = unicode(int(enum.value)-1)
     379                    enum.update(db=db)
     380            except ValueError:
     381                pass # Ignore cast error for this non-essential operation
    376382
    377383        if handle_ta:
    378384            db.commit()

I am quite sure that is a good working solution, but wouldn't mind confirmation.

comment:6 by sid, 16 years ago

#6494 was marked as duplicate of this ticket.

comment:7 by osimons, 16 years ago

Milestone: 0.11.10.11
Resolution: fixed
Status: newclosed

Patch (with comments from cmlenz) applied as [6323]. Sorry for the inconvenience - hope this does it :-)

in reply to:  7 comment:8 by jason, 16 years ago

Replying to osimons:

Patch (with comments from cmlenz) applied as [6323]. Sorry for the inconvenience - hope this does it :-)

Seems OK now. And deleting / recreating all prioroties fixed up the ordering and ticket coloring.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from osimons to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.