Index: node_age.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/spam/filters/node_age/Attic/node_age.module,v
retrieving revision 1.1.2.4.2.3
diff -u -r1.1.2.4.2.3 node_age.module
--- node_age.module	5 Aug 2009 15:27:58 -0000	1.1.2.4.2.3
+++ node_age.module	6 Aug 2009 14:06:04 -0000
@@ -60,22 +60,24 @@
  * Determine if a comment is being posted against too old of a node.
  */
 function node_age_spam_filter($content, $type, $fields, $extra = array(), $filter_test = FALSE) {
-  $action = array();
-  $id = spam_invoke_module($type, 'content_id', $content, $extra);
-  if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
-    $nid = arg(2);
-    if (!empty($nid)) {
+  if ($type == 'comment') {
+    $action = array();
+    $id = spam_invoke_module($type, 'content_id', $content, $extra);
+    if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
+      $nid = arg(2);
       spam_log(SPAM_DEBUG, 'node_age_spam_filter', t('retrieved nid (@nid) from url', array('@nid' => $nid)), $type, $id);
     }
-  }
-  else {
-    $nid = db_result(db_query('SELECT nid FROM {comments} WHERE cid = %d', $id));
-    if (!empty($nid)) {
+    else {
+      $nid = db_result(db_query('SELECT nid FROM {comments} WHERE cid = %d', $id));
       spam_log(SPAM_DEBUG, 'node_age_spam_filter', t('retrieved nid (@nid) from database', array('@nid' => $nid)), $type, $id);
     }
-  }
 
-  if ($type == 'comment' && $nid) {
+    if (!$nid) {
+      spam_log(SPAM_VERBOSE, 'node_age_spam_filter', t('warning: nid not found for comment (@cid), skipping', array('@cid' => $id)), $type, $id);
+      $action['total'] = 0;
+      return $action;
+    }
+
     $node = spam_invoke_module('node', 'load', $nid);
     if (is_object($node)) {
       $timestamp_field = variable_get('node_age_filter_on', 'created');
@@ -91,6 +93,9 @@
         $action['total'] = 0;
         spam_log(SPAM_DEBUG, 'node_age_spam_filter', t('node (@nid) is recent.', array('@nid' => $nid)), $type, $id);
       }
+    } else {
+      spam_log(SPAM_VERBOSE, 'node_age_spam_filter', t('warning: nid (@nid) does not map to node, skipping', array('@nid' => $nid)), $type, $id);
+      $action['total'] = 0;
     }
   }
   else {
