Bug in states?

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
Als
Posts: 1
Joined: Tue May 13, 2008 6:49 am

Bug in states?

Post 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?
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

mmm... I think you are right... this is a bug. But this should be confirmed by developers.
User avatar
Normando
Posts: 219
Joined: Sun Aug 17, 2008 5:34 am
Location: Rosario - Argentina

Post by Normando »

User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Fixed in 1.24.2
Post Reply