From c080dd8a12a2c574ef375b1c9cc2e4eb05836f3f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 May 2021 15:27:36 -0400 Subject: [PATCH] Fixes #2992. If no definition for a monitor is found, don't modify it. --- scripts/zmpkg.pl.in | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index 2f6708fc8..3302b0019 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -103,18 +103,17 @@ if ( $command eq 'state' ) { or Fatal("Can't prepare '$sql': ".$dbh->errstr()); my $res = $sth->execute($Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID}: ()) or Fatal("Can't execute: ".$sth->errstr()); - while( my $monitor = $sth->fetchrow_hashref() ) { + while ( my $monitor = $sth->fetchrow_hashref() ) { foreach my $definition ( @{$state->{Definitions}} ) { if ( $monitor->{Id} =~ /^$definition->{Id}$/ ) { $monitor->{NewFunction} = $definition->{Function}; $monitor->{NewEnabled} = $definition->{Enabled}; + last; } } - #next if ( !$monitor->{NewFunction} ); - $monitor->{NewFunction} = 'None' - if ( !$monitor->{NewFunction} ); - $monitor->{NewEnabled} = 0 - if ( !$monitor->{NewEnabled} ); + next if ! exists $monitor->{NewFunction}; + $monitor->{NewFunction} = 'None' if !$monitor->{NewFunction}; + $monitor->{NewEnabled} = 0 if !$monitor->{NewEnabled}; if ( $monitor->{Function} ne $monitor->{NewFunction} || $monitor->{Enabled} ne $monitor->{NewEnabled} ) {