Page 1 of 1

zmfilter.pl dies with Can't use an undefined value as an ARR

Posted: Fri Dec 31, 2010 11:09 am
by arekm
My zmfilter.pl dies:
31.12.2010 12:06:21.059348 zmdc[29093].INF [Starting pending process, zmfilter.pl]
31.12.2010 12:06:21.061099 zmdc[29093].INF ['zmfilter.pl' starting at 10/12/31 12:06:21, pid = 29467]

==> /var/log/zoneminder/zmfilter.log <==
31.12.2010 12:06:22.099172 zmfilter[29467].INF [Scanning for events]

==> /var/log/zoneminder/zmdc.log <==
31.12.2010 12:06:27.148332 zmdc[29093].ERR ['zmfilter.pl ' exited abnormally, exit status 9]




I was able to strace zmfilter.pl process and this came up:

Can't use an undefined value as an ARRAY reference at /usr/bin/zmfilter.pl line 273

where

266 FILTER: while( my $db_filter = $sth->fetchrow_hashref() )
267 {
268 Debug( "Found filter '$db_filter->{Name}'\n" );
269 my $filter_expr = unserialize( $db_filter->{Query} );
270 my $sql = "select E.Id,E.MonitorId,M.Name as MonitorName,M.DefaultRate,M.DefaultScale,E.Name,E.Cause,E.Notes,E.StartTime,unix_timestamp(E.Sta
rtTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.Videoed,E.Uploaded,E.Emailed,E.Messaged,E.Executed from Events
as E inner join Monitors as M on M.Id = E.MonitorId where not isnull(E.EndTime)";
271 $db_filter->{Sql} = '';
272
273 if ( @{$filter_expr->{terms}} )
274 {
275 for ( my $i = 0; $i < @{$filter_expr->{terms}}; $i++ )



any clues?

proposed fix

Posted: Thu Jan 20, 2011 8:48 am
by arekm
Shouldn't this be like this?

Code: Select all

--- /usr/bin/zmfilter.pl~       2010-06-29 21:30:39.000000000 +0200
+++ /usr/bin/zmfilter.pl        2011-01-20 09:45:48.000000000 +0100
@@ -270,7 +270,7 @@
         my $sql = "select E.Id,E.MonitorId,M.Name as MonitorName,M.DefaultRate,M.DefaultScale,E.Name,E.Cause,E.Notes,E.StartTime,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.Videoed,E.Uploaded,E.Emailed,E.Messaged,E.Executed from Events as E inner join Monitors as M on M.Id = E.MonitorId where not isnull(E.EndTime)";
            $db_filter->{Sql} = '';

-        if ( @{$filter_expr->{terms}} )
+        if ( $filter_expr->{terms} )
         {
             for ( my $i = 0; $i <filter_expr>{terms}}; $i++ )
             {