Modify

Opened 8 years ago

Closed 8 years ago

#13104 closed defect (fixed)

set_owner_to_component_owner should check existence of selected component

Reported by: Jun Omae Owned by: Eli Carter
Priority: normal Component: AdvancedTicketWorkflowPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

If set_owner_to_component_owner operation is used in workflow and component of the ticket is removed, auto-preview wouldn't work by 404 not found.

How to reproduce:

  1. Use set_owenr_to_component_owner operation
  2. Add blahblah to component
  3. Create new ticket with component1
  4. Visit the ticket
  5. Remove blahblah component
  6. Select blahblah component
  7. Auto-preview receives 404 response and doesn't work
2017-03-08 19:25:32,842 Trac[main] WARNING: [192.168.11.21] HTTPNotFound: 404 Trac Error (Component blahblah does not exist.)
  • advancedworkflow/controller.py

    diff --git a/advancedworkflow/controller.py b/advancedworkflow/controller.py
    index d8cac545b..c5fb3c452 100644
    a b from trac.ticket.model import Milestone 
    1616from trac.ticket.notification import TicketNotifyEmail
    1717from trac.resource import ResourceNotFound
    1818from trac.util.datefmt import utc
     19from trac.util.text import to_unicode
    1920from trac.web.chrome import add_warning
    2021
    2122
    class TicketWorkflowOpOwnerComponent(TicketWorkflowOpBase): 
    126127
    127128    def _new_owner(self, ticket):
    128129        """Determines the new owner"""
    129         component = model.Component(self.env, name=ticket['component'])
    130         self.env.log.debug("component %s, owner %s" % (component, component.owner))
    131         return component.owner
     130        try:
     131            component = model.Component(self.env, name=ticket['component'])
     132            return component.owner
     133        except ResourceNotFound, e:
     134            self.log.warning("In %s, %s", self._op_name, to_unicode(e))
     135            return None
    132136
    133137
    134138class TicketWorkflowOpOwnerField(TicketWorkflowOpBase):

After the patch: owner of the ticket would be deleted if selected component isn't existent.

2017-03-08 19:38:46,993 Trac[controller] WARNING: In set_owner_to_component_owner, Component blahblah does not exist.

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by Jun Omae

reset_milestone operation has the same issue about milestone of the ticket.

  • advancedworkflow/controller.py

    diff --git a/advancedworkflow/controller.py b/advancedworkflow/controller.py
    index c5fb3c452..f4f12d9b7 100644
    a b class TicketWorkflowOpResetMilestone(TicketWorkflowOpBase): 
    509509
    510510    def get_ticket_changes(self, req, ticket, action):
    511511        """Returns the change of milestone, if needed."""
    512         milestone = Milestone(self.env,ticket['milestone'])
    513         if milestone.is_completed:
     512        milestone = self._fetch_milestone(ticket)
     513        if milestone and milestone.is_completed:
    514514            return {'milestone': ''}
    515515        return {}
     516
     517    def _fetch_milestone(self, ticket):
     518        if ticket['milestone']:
     519            try:
     520                return Milestone(self.env, ticket['milestone'])
     521            except ResourceNotFound, e:
     522                self.log.warning("In %s, %s", self._op_name, to_unicode(e))
     523        return None

comment:2 Changed 8 years ago by Jun Omae

Resolution: fixed
Status: newclosed

In 16306:

AdvancedTicketWorkflowPlugin/0.12: check existance of milestone and component in operations (closes #13104)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Eli Carter.
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.