[rt-users] Scrips firing at will - huh?
Todd Chapman
todd at chaka.net
Tue Dec 6 11:31:39 EST 2005
Looking at your scrip, I don't think you should be calling die
from a scrip. You should log the error with $RT::Logger->error
and then return 0.
-Todd
On Tue, Dec 06, 2005 at 09:33:02AM +0100, Leif Nixon wrote:
> OK, I thought I had some basic understanding of the scrip mechanism,
> but this is just weird...
>
> I'm running RT 3.4.4 with fastcgi on an Apache 2.
>
> I have a AutoTake scrip on the form "On Correspond User Defined with
> template Blank". That "User Defined" bit is a short Perl snippet that
> checks if the current ticket owner is Nobody, and if so, assigns the
> ticket to the current user. The entire snippet is located in the
> "Custom action preparation code" part of the scrip, which is perhaps
> not a good idea. (I'm including the Perl code at the end of this mail
> for the sake of completeness.)
>
> I also have the standard "On Owner Change Notify Owner" scrip.
>
> Now the strange thing: If a user clicks one of the "Reply" links in
> the history of an unowned ticket (on the ordinary Ticket/Display.html
> page), he gets a notification from the Owner Change scrip that he is
> now the owner of the ticket. Note that this is when he just clicks the
> "Reply" link, before he has actually entered a reply and updated the
> ticket!
>
> Furthermore, if you at this point cancel the reply and return to the
> ticket display, it turns out that the ticket still is ownerless. It
> has in fact *not* been assigned to the user, but still the Owner
> Change scrip fired.
>
> I have experimented with splitting the Perl code from the AutoTake
> scrip, so that the check for an ownerless ticket goes in the "action
> preparation" part, and the actual SetOwner() call goes in the "action
> cleanup" part, which seems to help, but I still don't understand the
> anomalous behaviour.
>
> Could someone spread some light on this?
>
> ------
> The code from the scrip:
>
> my $ticket = $self->TicketObj;
> if ($ticket->OwnerObj->Id == $RT::Nobody->Id) {
> my $Actor = $self->TransactionObj->CreatorObj->Id;
> if ($Actor != $ticket->OwnerObj->Id) {
> $RT::Logger->info("Auto assign ticket #". $ticket->id ." to user #". $Actor );
>
> my ($status, $msg) = $ticket->SetOwner( $Actor );
> unless( $status ) {
> die "Error: $msg";
> }
> }
> return( 1 );
> }
> else {
> return(undef);
> }
>
> --
> Leif Nixon - Systems expert
> ------------------------------------------------------------
> ppNational Supercomputer Centre - Linkoping University
> ------------------------------------------------------------
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Be sure to check out the RT Wiki at http://wiki.bestpractical.com
>
> Download a free sample chapter of RT Essentials from O'Reilly Media at http://rtbook.bestpractical.com
>
> WE'RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and
> San Francisco - Find out more at http://bestpractical.com/services/training.html
More information about the rt-users
mailing list