OneTicketPerRequestor: Handle more YAML errors.

This avoids dying in cases where the YAML file is empty or malformed.
This commit is contained in:
Brett Smith 2018-04-26 09:46:11 -04:00
parent 325c5ceaf6
commit 727d9d5659

View file

@ -18,11 +18,9 @@ my $plugin_self = RT::Plugin->new(name => "RT-Extension-Conservancy");
foreach my $confdir ($plugin_self->Path("etc"), $RT::LocalEtcPath, $RT::EtcPath) { foreach my $confdir ($plugin_self->Path("etc"), $RT::LocalEtcPath, $RT::EtcPath) {
next unless (defined($confdir) && $confdir); next unless (defined($confdir) && $confdir);
my $conf_path = "$confdir/OneTicketPerRequestor.yml"; my $conf_path = "$confdir/OneTicketPerRequestor.yml";
if (-r $conf_path) { eval { %QUEUES = %{YAML::Tiny->read($conf_path)->[0]} };
%QUEUES = %{YAML::Tiny->read($conf_path)->[0]};
last if (%QUEUES); last if (%QUEUES);
} }
}
# Compile the user's configuration into arguments for RT::Tickets->OrderBy. # Compile the user's configuration into arguments for RT::Tickets->OrderBy.
while (my ($key, $sort_orders) = each %QUEUES) { while (my ($key, $sort_orders) = each %QUEUES) {