Opened 16 months ago
Last modified 4 months ago
#14241 new defect
TicketStencilPlugin doesn't work if ticket types contain uppercase letters
Reported by: | 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
43 43 all_types = [enum.name for enum in Type.select(self.env)] 44 44 for name in self.wiki_system.get_pages('TicketStencil'): 45 45 page = WikiPage(env = self.env, name = name) 46 ticket_type = name[prefix_len:] .lower()47 stencils[ticket_type ] = page.text46 ticket_type = name[prefix_len:] 47 stencils[ticket_type.lower()] = page.text 48 48 try: 49 49 all_types.remove(ticket_type) 50 50 except ValueError:
I've encountered this issue also. Fixed it locally, but would be nice if it was also fixed in subversion repository.