Modify

Opened 16 months ago

Last modified 4 months ago

#14241 new defect

TicketStencilPlugin doesn't work if ticket types contain uppercase letters

Reported by: khym@… Owned by: tkob-trac
Priority: normal Component: TicketStencilPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

I installed the TicketStencilPlugin on Trac 1.5.4 and Python 3.11, ran trac-admin deploy to install the .js file, and created a TicketStencilBug wiki page, but it didn't populate the ticket description for me. Looking at the source of the newticket page, I saw:

var _tracticketstencil={"_ticketstencil_default_type":"","bug":"","enhancement":"","task":""};

So it was finding my ticket types, but not getting the stencil for any of them. Looking into it further, I found that the problem is that it sets the stencils, then in another loop, ends up clearing all of them. The all_types list has the ticket types in the original case, but the ticket_type variable is all lowercase. If a ticket type has uppercase letters, all_types.remove(ticket_type) will throw a ValueError('list.remove(x): x not in list') because of the case mismatch. Then when it later does "Set defaults for remaining ticket types", all_types will still contain all of the ticket types, and the stencils for all types will be set to the empty string.

Patch:

  • ticketstencil.py

     
    4343        all_types = [enum.name for enum in Type.select(self.env)]
    4444        for name in self.wiki_system.get_pages('TicketStencil'):
    4545            page = WikiPage(env = self.env, name = name)
    46             ticket_type = name[prefix_len:].lower()
    47             stencils[ticket_type] = page.text
     46            ticket_type = name[prefix_len:]
     47            stencils[ticket_type.lower()] = page.text
    4848            try:
    4949                all_types.remove(ticket_type)
    5050            except ValueError:

Attachments (0)

Change History (1)

comment:1 Changed 4 months ago by Hans Dijkema

I've encountered this issue also. Fixed it locally, but would be nice if it was also fixed in subversion repository.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain tkob-trac.

Add Comment


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

 
Note: See TracTickets for help on using tickets.