--- spam/spam.module	2010-12-24 22:40:01.000000000 -0800
+++ spam/spam.module.orig	2010-12-25 20:35:06.834827736 -0800
@@ -46,22 +46,22 @@
   }
   $id = spam_invoke_module($type, 'content_id', $content, $extra);
   spam_log(SPAM_DEBUG, 'spam_scan', t('scanning content'), $type, $id);
-  spam_update_statistics(t('scan @type', array('@type' => $type)));
+  _spam_update_statistics(t('scan @type', array('@type' => $type)));
   if (spam_content_is_spam($content, $type, $extra, $filter_test)) {
     spam_log(SPAM_DEBUG, 'spam_scan', t('content is spam'), $type, $id);
-    spam_update_statistics(t('detected spam @type', array('@type' => $type)));
+    _spam_update_statistics(t('detected spam @type', array('@type' => $type)));
     switch (variable_get('spam_visitor_action', SPAM_ACTION_PREVENT)) {
       case SPAM_ACTION_PREVENT:
         spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(prevent)'), $type, $id);
       default:
         $_SESSION['content'] = serialize((array)$content);
         $_SESSION['type'] = $type;
-        spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
+        _spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
         drupal_goto('spam/denied');
 
       case SPAM_ACTION_PREVENT_SILENT:
         spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(prevent silently)'), $type, $id);
-        spam_update_statistics(t('silently prevented spam @type', array('@type' => $type)));
+        _spam_update_statistics(t('silently prevented spam @type', array('@type' => $type)));
         if ($id) {
           // Content was already published, so we unpublish it.
           spam_unpublish($type, $id, $extra);
@@ -73,7 +73,7 @@
 
       case SPAM_ACTION_UNPUBLISH:
         spam_log(SPAM_LOG, 'spam_scan', t('content is spam, action(unpublish)'), $type, $id);
-        spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
+        _spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
         if ($id) {
           spam_unpublish($type, $id, $extra);
         }
@@ -187,10 +187,10 @@
         }
       }
       else {
-        spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
+        _spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
       }
-      spam_update_statistics(t('detected spam'));
-      spam_update_statistics(t('content_filter redirect'));
+      _spam_update_statistics(t('detected spam'));
+      _spam_update_statistics(t('content_filter redirect'));
       spam_log(SPAM_VERBOSE, 'spam_content_filter', t('Spam score [!score], redirecting to: !url', array('!score' => $log_score, '!url' => $redirect)), $type, $id);
       drupal_goto($redirect);
     }
@@ -269,7 +269,7 @@
     spam_mark_as_spam($type, $id, $extra);
     $_SESSION['content'] = serialize((array)$content);
     $_SESSION['type'] = $type;
-    spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
+    _spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
     spam_log(SPAM_DEBUG, 'spam_content_insert', t('redirecting to spam/denied'), $type, $id);
     drupal_goto('spam/denied');
   }
@@ -335,7 +335,7 @@
     spam_mark_as_spam($type, $id, $extra);
     $_SESSION['content'] = serialize((array)$content);
     $_SESSION['type'] = $type;
-    spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
+    _spam_update_statistics(t('prevented spam @type', array('@type' => $type)));
     spam_log(SPAM_DEBUG, 'spam_content_update', t('redirecting to spam/denied'), $type, $id);
     drupal_goto('spam/denied');
   }
@@ -397,11 +397,12 @@
 /**
  * Increment internal counters.
  */
-function spam_update_statistics($name, $op = '+', $inc = 1) {
+function _spam_update_statistics($name, $op = '+', $inc = 1) {
+  spam_log(LOG_DEBUG, 'spam_update_statistics', t('@name = @name @op @inc', array('@name' => $name, '@op' => $op, '@inc' => $inc)));
   if ($op != '+' && $op != '-') {
     watchdog('spam', 'Invalid operator(@op), ignored.', array('@op' => $op));
+    return;
   }
-  spam_log(LOG_DEBUG, 'spam_update_statistics', t('@name = @name @op @inc', array('@name' => $name, '@op' => $op, '@inc' => $inc)));
   db_query("UPDATE {spam_statistics} SET count = count %s %d, timestamp = %d WHERE name = '%s'", $op, $inc, time(), $name);
   if (!db_affected_rows()) {
     if ($op == '-') {
@@ -569,10 +570,10 @@
   if (is_numeric($id) && ($action == 'spam' || $action == 'not_spam')) {
     if (spam_invoke_module($type, 'content_module') == $type) {
       if ($action == 'spam') {
-        spam_update_statistics(t('@type manually marked as spam', array('@type' => $type)));
+        _spam_update_statistics(t('@type manually marked as spam', array('@type' => $type)));
       }
       else {
-        spam_update_statistics(t('@type manually marked as not spam', array('@type' => $type)));
+        _spam_update_statistics(t('@type manually marked as not spam', array('@type' => $type)));
       }
       return $type;
     }
@@ -1716,7 +1717,7 @@
   }
   $loop[$id] = TRUE;
 
-  spam_update_statistics(t('@type marked as spam', array('@type' => $type)));
+  _spam_update_statistics(t('@type marked as spam', array('@type' => $type)));
   $extra['sid'] = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = %d", $type, $id));
   if (!$extra['score']) {
     $extra['score'] = 99;
@@ -1758,7 +1759,7 @@
   }
   $loop[$id] = TRUE;
 
-  spam_update_statistics(t('@type marked as not spam', array('@type' => $type)));
+  _spam_update_statistics(t('@type marked as not spam', array('@type' => $type)));
   $extra['sid'] = db_result(db_query("SELECT sid FROM {spam_tracker} WHERE content_type = '%s' AND content_id = %d", $type, $id));
   if (!$extra['score']) {
     $extra['score'] = 1;
@@ -2082,7 +2083,7 @@
   spam_log(SPAM_VERBOSE, 'spam_unpublish', t('unpublished'), $type, $id);
   spam_invoke_module($type, 'unpublish', $id, $extra);
   cache_clear_all();
-  spam_update_statistics(t('unpublish @type', array('@type' => $type)));
+  _spam_update_statistics(t('unpublish @type', array('@type' => $type)));
 }
 
 /**
@@ -2093,5 +2094,5 @@
   spam_log(SPAM_VERBOSE, 'spam_publish', t('published'), $type, $id);
   spam_invoke_module($type, 'publish', $id, $extra);
   cache_clear_all();
-  spam_update_statistics(t('publish @type', array('@type' => $type)));
+  _spam_update_statistics(t('publish @type', array('@type' => $type)));
 }
