[rt-users] Hook::LexWrap

Tony Bowden rt at tmtm.com
Tue Sep 21 14:20:44 EDT 2004


One of the things I had to check when we upgraded was that the
MergeTicket functionality hadn't changed significantly, as we've
overridden it locally.

When I talked to Jesse about this at Foo he suggested using
Hook::LexWrap instead. I've just spent a frustrating half hour or so
trying to find a way to get this to work. It appears that LexWrap
doesn't like the way that the Ticket modules are evalled in, as it can't
find the subref to wrap.

For now I've gone with rolling my own:

  no warnings 'redefine';

  our $orig = \&RT::Ticket::MergeInto or die "Can't find original";

  *RT::Ticket::MergeInto = sub {
    my ($self, $MergeInto) = @_;

    # Load up the new ticket.
    my $NewTicket = RT::Ticket->new($RT::SystemUser);
    $NewTicket->Load($MergeInto);

    my $customer = $self->FirstCustomFieldValue('Customer')
      or return (0, "Can't merge customerless ticket");

    my $customer2 = $NewTicket->FirstCustomFieldValue('Customer');
    return (0, "Customer is different! ($customer vs $customer2)")
      unless $customer eq $customer2;
    goto $orig;
	};


This seems to work well enough, but I'd be keen to discover the mystical
incantation to get LexWrap to do it for me.

Thanks,

Tony





More information about the rt-users mailing list