You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/02/19 03:12:42 UTC

svn commit: rev 6751 - incubator/spamassassin/trunk/lib/Mail/SpamAssassin

Author: felicity
Date: Wed Feb 18 18:12:40 2004
New Revision: 6751

Modified:
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
Log:
bug 2261: change the 'db not initialised' message to be more meaningful -- none of the message's tokens were found in the db.

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm	Wed Feb 18 18:12:40 2004
@@ -1049,7 +1049,6 @@
   }
 
   my %seen = ();
-  my $pw;
 
   my $msgatime = $self->receive_date(scalar $msg->get_all_headers(0,1));
 
@@ -1057,7 +1056,7 @@
   # future, something's messed up and we should revert to current time as
   # a safety measure.
   #
-  $msgatime = time if ( $msgatime - time > 86400 );
+  $msgatime = time if ( $msgatime > time );
 
   my %pw = map {
     if ($seen{$_}) {
@@ -1065,7 +1064,7 @@
     } else {
       $seen{$_} = 1;
       # warn "JMD bayes token found: '$_'\n";
-      $pw = $self->compute_prob_for_token ($_, $ns, $nn);
+      my $pw = $self->compute_prob_for_token ($_, $ns, $nn);
       if (!defined $pw) {
 	();		# exit map()
       } else {
@@ -1074,6 +1073,13 @@
     }
   } @tokens;
 
+  # If none of the tokens were found in the DB, we're going to skip
+  # this message...
+  if (!keys %pw) {
+    dbg ("cannot use bayes on this message; none of the tokens were found in the database");
+    goto skip;
+  }
+
   # now take the $count most significant tokens and calculate probs using
   # Robinson's formula.
   my $count = N_SIGNIFICANT_TOKENS;
@@ -1092,11 +1098,6 @@
     $self->{store}->tok_touch ($_, $msgatime);
 
     dbg ("bayes token '$_' => $pw");
-  }
-
-  if ($#sorted < 0) {
-    dbg ("cannot use bayes on this message; db not initialised yet");
-    goto skip;
   }
 
   if (REQUIRE_SIGNIFICANT_TOKENS_TO_SCORE > 0 &&