Page 1 of 1

Bug in states?

Posted: Tue May 13, 2008 7:16 am
by Als
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:

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         }
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?

Posted: Sun Nov 30, 2008 4:18 am
by Normando
mmm... I think you are right... this is a bug. But this should be confirmed by developers.

Posted: Sun Jun 28, 2009 6:57 am
by Normando

Posted: Tue Jul 07, 2009 2:28 am
by cordel
Fixed in 1.24.2