Bug in states?
Posted: Tue May 13, 2008 7:16 am
Hi!
I try setup simple day/night states with one monitor with ZoneMinder 1.22.3. I create monitor with function Modect and two states: Night with disabled and Day with enabled. Save this states works fine and in MySQL I can check it's all right.
Changing state from Day to Night corectly disable function. But Night to Day do not work right and Modect function not enabled.
In zmpkg.pl I found:
I wonder what line 125 do. It seems monitor never be enabled if is once disabled. Line first appear in 1.22.0 and still be in latest 1.23.3. I'am not familiar with perl and ZoneMinder overall, but I take out line 125 and now states works corectly. I missing somethings or it's long time bug and no one using states?
I try setup simple day/night states with one monitor with ZoneMinder 1.22.3. I create monitor with function Modect and two states: Night with disabled and Day with enabled. Save this states works fine and in MySQL I can check it's all right.
Changing state from Day to Night corectly disable function. But Night to Day do not work right and Modect function not enabled.
In zmpkg.pl I found:
Code: Select all
113 while( my $monitor = $sth->fetchrow_hashref() )
114 {
115 foreach my $definition ( @{$state->{Definitions}} )
116 {
117 if ( $monitor->{Id} =~ /^$definition->{Id}$/ )
118 {
119 $monitor->{NewFunction} = $definition->{Function};
120 $monitor->{NewEnabled} = $definition->{Enabled};
121 }
122 }
123 #next if ( !$monitor->{NewFunction} );
124 $monitor->{NewFunction} = 'None' if ( !$monitor->{NewFunction} );
125 $monitor->{NewEnabled} = 0 if ( !$monitor->{Enabled} );
126 if ( $monitor->{Function} ne $monitor->{NewFunction} || $monitor->{Enabled} ne $monitor->{NewEnabled} )
127 {
128 my $sql = "update Monitors set Function = ?, Enabled = ? where Id = ?";
129 my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
130 my $res = $sth->execute( $monitor->{NewFunction}, $monitor->{NewEnabled}, $monitor->{Id} ) or Fatal( "Can't execute: ".$sth->errstr() );
131 }
132 }