fix "Can' tuse an undefined value as an ARRAY reference" error for new virtual ports...
authorivan <ivan>
Tue, 27 Sep 2011 18:38:14 +0000 (18:38 +0000)
committerivan <ivan>
Tue, 27 Sep 2011 18:38:14 +0000 (18:38 +0000)
FS/bin/freeside-torrus-srvderive

index 56535f9..5ad23ab 100644 (file)
@@ -82,7 +82,8 @@ while (1) {
                     ORDER BY srv_date LIMIT 1";
         my $dsth = dbh->prepare($dsql) or die $DBI::errstr;
         $dsth->execute or die $dsth->errstr;
-        my $date = $dsth->fetchrow_arrayref->[0];
+        my $row = $dsth->fetchrow_arrayref;
+        my $date = (defined($row) && ref($row)) ? $row->[0] : '';
         if ( $date ) {
           warn "found initial last_srv_date of $date; updating $serviceid\n"
             if $DEBUG;