Browse Source

kohabug 2345: bad comparisons pervade reports

This patch changes all $foo eq undef's to !defined($foo). It also makes misc/spellcheck_suggest/build_spellcheck_suggest.pl have proper syntax.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
3.0.x
Jesse Weaver 16 years ago
committed by Joshua Ferraro
parent
commit
ac0d340bd5
  1. 2
      cataloguing/addbiblio.pl
  2. 2
      misc/cronjobs/holds/build_holds_queue.pl
  3. 6
      misc/spellcheck_suggest/make_spellcheck_suggest.pl
  4. 6
      reports/acquisitions_stats.pl
  5. 4
      reports/bor_issues_top.pl
  6. 2
      reports/borrowers_out.pl
  7. 6
      reports/borrowers_stats.pl
  8. 2
      reports/cat_issues_top.pl
  9. 6
      reports/catalogue_stats.pl
  10. 6
      reports/issues_avg_stats.pl

2
cataloguing/addbiblio.pl

@ -84,7 +84,7 @@ sub MARCfindbreeding {
}
}
if ( ref($record) eq undef ) {
if ( !defined(ref($record)) ) {
return -1;
}
else {

2
misc/cronjobs/holds/build_holds_queue.pl

@ -152,7 +152,7 @@ sub randarray {
$rand[$randnum] = shift(@array);
while (1) {
my $randnum = int(rand($seed));
if ($rand[$randnum] eq undef) {
if (!defined($rand[$randnum])) {
$rand[$randnum] = shift(@array);
}
last if ($#array == -1);

6
misc/spellcheck_suggest/make_spellcheck_suggest.pl

@ -83,7 +83,7 @@ use C4::Context;
# and uncomment the one after it, adding your site info (check out GRANT
# syntax in the mysql manual if you're unsure how enable authentication)
#
my dbh2 = C4::Context->dbh;
my $dbh2 = C4::Context->dbh;
#
#my $dbh2=DBI->connect("DBI:mysql:<add your database name here>:localhost","<add your mysql user here>","<add your password here>");
########################################################################
@ -97,12 +97,10 @@ my $counter = 0;
print "Step 1 of 5: Checking to make sure suggest tables exist\n";
my $check_tables_query = "select distinct resultcount from ?";
my @tables = ("notdistinctspchk", "notdistinctsugg", "spellcheck", "suggestions");
my %tables = ( notdistinctspchk => "( display varchar(40) not null default,
suggestion varchar(40) not null default,
foreach my $table (@tables) {
my $sth_check=$dbh2->prepare($check_tables_query) || die "cant prepare query: $DBI::errstr";
my $rv = $sth_check->execute($table);
if($rv eq undef) {
if(!defined($rv)) {
print "$table missing ... creating it now\n";
my $create_this = "CREATE TABLE \'$table\' \(
display varchar\(40\) NOT NULL default \'\',

6
reports/acquisitions_stats.pl

@ -657,9 +657,9 @@ sub calculate {
while ( my ( $row, $col, $value ) = $dbcalc->fetchrow ) {
next if ($row eq undef || $col eq undef);
#warn "filling table $row / $col / $value ";
$emptycol = 1 if ( $col eq undef );
$col = "zzEMPTY" if ( $col eq undef );
$row = "zzEMPTY" if ( $row eq undef );
$emptycol = 1 if ( !defined($col) );
$col = "zzEMPTY" if ( !defined($col) );
$row = "zzEMPTY" if ( !defined($row) );
$table{$row}->{$col} += $value;
$table{$row}->{totalrow} += $value;

4
reports/bor_issues_top.pl

@ -340,7 +340,7 @@ sub calculate {
# )
while (my @data = $dbcalc->fetchrow) {
my ($row, $rank, $id, $col) = @data;
$col = "zzEMPTY" if ($col eq undef);
$col = "zzEMPTY" if (!defined($col));
unless ($patrons{$id}) {
$patrons{$id} = {name=>$row, allcols=>{}, newcols=>{}, oldcols=>{}};
}
@ -356,7 +356,7 @@ sub calculate {
$debug and print DEBUG "rows: ", $dbcalc->rows, "\n";
while (my @data = $dbcalc->fetchrow) {
my ($row, $rank, $id, $col) = @data;
$col = "zzEMPTY" if ($col eq undef);
$col = "zzEMPTY" if (!defined($col));
unless ($patrons{$id}) {
$patrons{$id} = {name=>$row, allcols=>{}, newcols=>{}, oldcols=>{}};
}

2
reports/borrowers_out.pl

@ -273,7 +273,7 @@ sub calculate {
$i=1;
while (my @data = $dbcalc->fetchrow) {
my ($row, $col )=@data;
$col = "zzEMPTY" if ($col eq undef);
$col = "zzEMPTY" if (!defined($col));
$i=1 if (($previous_col) and not($col eq $previous_col));
$table[$i]->{$col}=$row;
# warn " $i $col $row";

6
reports/borrowers_stats.pl

@ -327,9 +327,9 @@ sub calculate {
my $emptycol;
while (my ($row, $col, $value) = $dbcalc->fetchrow) {
# warn "filling table $row / $col / $value ";
$emptycol = 1 if ($col eq undef);
$col = "zzEMPTY" if ($col eq undef);
$row = "zzEMPTY" if ($row eq undef);
$emptycol = 1 if (!defined($col));
$col = "zzEMPTY" if (!defined($col));
$row = "zzEMPTY" if (!defined($row));
$table{$row}->{$col}+=$value;
$table{$row}->{totalrow}+=$value;

2
reports/cat_issues_top.pl

@ -378,7 +378,7 @@ sub calculate {
my %indice;
while (my @data = $dbcalc->fetchrow) {
my ($row, $rank, $id, $col )=@data;
$col = "zzEMPTY" if ($col eq undef);
$col = "zzEMPTY" if (!defined($col));
$indice{$col}=1 if (not($indice{$col}));
$table[$indice{$col}]->{$col}->{'name'}=$row;
$table[$indice{$col}]->{$col}->{'count'}=$rank;

6
reports/catalogue_stats.pl

@ -432,9 +432,9 @@ sub calculate {
my $emptycol;
while (my ($row, $col, $value) = $dbcalc->fetchrow) {
# warn "filling table $row / $col / $value ";
$emptycol = 1 if ($col eq undef);
$col = "zzEMPTY" if ($col eq undef);
$row = "zzEMPTY" if ($row eq undef);
$emptycol = 1 if (!defined($col));
$col = "zzEMPTY" if (!defined($col));
$row = "zzEMPTY" if (!defined($row));
$table{$row}->{$col}+=$value;
$table{$row}->{totalrow}+=$value;

6
reports/issues_avg_stats.pl

@ -543,9 +543,9 @@ sub calculate {
while (my @data = $dbcalc->fetchrow) {
my ($row, $col, $issuedate, $returndate, $weight)=@data;
# warn "filling table $row / $col / $issuedate / $returndate /$weight";
$emptycol=1 if ($col eq undef);
$col = "zzEMPTY" if ($col eq undef);
$row = "zzEMPTY" if ($row eq undef);
$emptycol=1 if (!defined($col));
$col = "zzEMPTY" if (!defined($col));
$row = "zzEMPTY" if (!defined($row));
# fill returndate to avoid an error with date calc (needed for all non returned issues)
$returndate= join '-',Date::Calc::Today if $returndate eq '0000-00-00';
# DateCalc returns => 0:0:WK:DD:HH:MM:SS the weeks, days, hours, minutes,

Loading…
Cancel
Save