David Schulz wrote:
Problem:
When i click on the Analysis Button on the Webui, i get a "Internal
Server Error" from Apache. The Error Log yields
Can't use an undefined value as an ARRAY reference at
/usr/local/www/cgi-bin/dspam/dspam.cgi line 551.
[Mon Feb 26 15:56:32 2007] [error] [client 208.14.54.204] Premature end
of script headers: /usr/local/www/cgi-bin/dspam/dspam.cgi
This happens when one of the three values to graph is null (i.e. no
data). I fixed this with the following change:
$ svn diff -r30:31
Index: dspam.cgi
===================================================================
--- dspam.cgi (revision 30)
+++ dspam.cgi (revision 31)
@@ -532,10 +532,13 @@
foreach my $period (qw( daily weekly )) {
my $uc_period=uc($period);
my $hk="DATA_$uc_period";
- my %lst=();
+ my %lst=(
+ spam => [],
+ nonspam => [],
+ title => []
+ );
foreach my $hr (sort {$a->{idx}<=>$b->{idx}} (values
%{$Stats{$period}})) {
foreach my $type (qw( spam nonspam title )) {
- (exists $lst{$type}) || ($lst{$type}=[]);
push(@{$lst{$type}},$hr->{$type});
my $totk="";
if ($type eq "spam") { $totk="S"; }
@@ -547,9 +550,9 @@
}
}
$DATA{$hk}=join("_",
- join(",",@{$lst{spam}}),
- join(",",@{$lst{nonspam}}),
- join(",",@{$lst{title}}),
+ join(",",@{$lst{spam}} || [0]),
+ join(",",@{$lst{nonspam}} || [0]),
+ join(",",@{$lst{title}} || [0]),
);
}
which is just better coding (i.e. provide a default value in case your
external data isn't present).
HTH
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5748