From fa32aeb9de4ad5abbc993e65c8de6a76aaf8e010 Mon Sep 17 00:00:00 2001 From: betateilchen <> Date: Fri, 21 Jul 2017 14:54:58 +0000 Subject: [PATCH] statistics2.cgi: fix for invalid rev id git-svn-id: https://svn.fhem.de/fhem/trunk@14754 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/statistics/2017/statistics2.cgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fhem/contrib/statistics/2017/statistics2.cgi b/fhem/contrib/statistics/2017/statistics2.cgi index 824340129..1f8ca7d64 100755 --- a/fhem/contrib/statistics/2017/statistics2.cgi +++ b/fhem/contrib/statistics/2017/statistics2.cgi @@ -86,21 +86,21 @@ sub insertDB() { my $json = $data{json}; my $geo = getLocation(); - $dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) || - die "Cannot connect: $DBI::errstr"; - my $decoded = decode_json($json); if (defined($decoded->{'system'}{'revision'})) { # replace revision number with revision date my $rev = $decoded->{'system'}{'revision'} + 1; if($rev =~ /^\d+$/) { my $d = (split(/ /,qx(sudo -u rko /usr/bin/svn info -r $rev $fhemPathSvn|grep Date:)))[3]; + return undef unless (defined($d)); my ($year,$mon,$mday) = split(/-/,$d); $decoded->{'system'}{'revdate'} = mktime(0,0,7,$mday,($mon-1),($year-1900),0,0,0); $json = encode_json $decoded; } } + $dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) || + die "Cannot connect: $DBI::errstr"; $sth = $dbh->prepare(q{INSERT OR REPLACE INTO jsonNodes(uniqueID,geo,json) VALUES(?,?,?)}); my $result = $sth->execute($uniqueID,$geo,$json); add2total() if $result;