OneTicketPerRequestor: Catch and report errors in the ticket search.

This commit is contained in:
Brett Smith 2018-04-10 10:44:13 -04:00
parent daeabc1aa6
commit d7a24b0f97

View file

@ -77,6 +77,7 @@ sub BeforeDecrypt {
return; return;
} }
my $dest_ticket = eval {
my $ticket_search = RT::Tickets->new($RT::SystemUser); my $ticket_search = RT::Tickets->new($RT::SystemUser);
$ticket_search->LimitQueue( $ticket_search->LimitQueue(
OPERATOR => "=", OPERATOR => "=",
@ -90,9 +91,13 @@ sub BeforeDecrypt {
foreach my $sort_args (@$sort_orders) { foreach my $sort_args (@$sort_orders) {
$ticket_search->OrderBy(@$sort_args); $ticket_search->OrderBy(@$sort_args);
} }
$ticket_search->First;
my $dest_ticket = $ticket_search->First; };
if (!defined($dest_ticket)) { if ($@) {
$RT::Logger->debug("OTPR stopping: Ticket search died: $@");
return;
}
elsif (!defined($dest_ticket)) {
$RT::Logger->debug(sprintf("OTPR stopping: No ticket found from <%s> in queue %s", $RT::Logger->debug(sprintf("OTPR stopping: No ticket found from <%s> in queue %s",
$from_address, $queue_name)); $from_address, $queue_name));
return; return;