kohabug 2345: bad comparisons pervade reports
authorJesse Weaver <jesse.weaver@liblime.com>
Fri, 25 Jul 2008 17:32:05 +0000 (12:32 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Sun, 27 Jul 2008 11:11:08 +0000 (06:11 -0500)
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>
cataloguing/addbiblio.pl
misc/cronjobs/holds/build_holds_queue.pl
misc/spellcheck_suggest/make_spellcheck_suggest.pl
reports/acquisitions_stats.pl
reports/bor_issues_top.pl
reports/borrowers_out.pl
reports/borrowers_stats.pl
reports/cat_issues_top.pl
reports/catalogue_stats.pl
reports/issues_avg_stats.pl

index 7713113..f811c83 100755 (executable)
@@ -84,7 +84,7 @@ sub MARCfindbreeding {
             }
         }
                
-        if ( ref($record) eq undef ) {
+        if ( !defined(ref($record)) ) {
             return -1;
         }
         else {
index 03a275f..e422248 100755 (executable)
@@ -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);
index 96ffea8..097e792 100755 (executable)
@@ -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 \'\',
index c5c4036..efa7bf2 100755 (executable)
@@ -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;
index 7761366..f9cf661 100755 (executable)
@@ -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=>{}};
                }
index e836017..763fa7e 100755 (executable)
@@ -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";
index df9e4df..b379067 100755 (executable)
@@ -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;
index b5db4ed..c11c899 100755 (executable)
@@ -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;
index 276294f..3addbe7 100755 (executable)
@@ -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;
index 8d9d70d..1153aa3 100755 (executable)
@@ -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,