From a605245cc14805cc51ce7a4489d51785804e2be0 Mon Sep 17 00:00:00 2001
From: Jesse Beach <splendidnoise@gmail.com>
Date: Sat, 12 Nov 2011 13:43:31 -0500
Subject: [PATCH] Issue #1006482 by jessebeach: Fixed comment module filter handler for user posted or user commented."

Signed-off-by: Jesse Beach <splendidnoise@gmail.com>
---
 .../views_handler_filter_comment_user_uid.inc      |   25 ++++++++++---------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/modules/comment/views_handler_filter_comment_user_uid.inc b/modules/comment/views_handler_filter_comment_user_uid.inc
index 9002019..08818bf 100644
--- a/modules/comment/views_handler_filter_comment_user_uid.inc
+++ b/modules/comment/views_handler_filter_comment_user_uid.inc
@@ -1,24 +1,25 @@
 <?php
 
 /**
- * Filter handler to accept a user id to check for nodes that user posted or
- * commented on.
+ * Filter handler to accept a user id and check for nodes that the user posted
+ * or commented on.
  */
 class views_handler_filter_comment_user_uid extends views_handler_filter_user_name {
   function query() {
     $this->ensure_my_table();
-
-    $subselect = db_select('comments', 'c');
-    $subselect->addField('c', 'cid');
-    $subselect->where("uid $this->operator $this->value");
-    $subselect->where("nid = $this->table_alias.nid");
-    $subselect = $subselect->countQuery();
-
+    // Create a views_join object.
+    $join = new views_join;
+    // Construct the join of the comment table on the base table where the nid
+    // fields in each table are equal.
+    $join->construct('comment',$this->table_alias,'nid','nid', array(),'LEFT OUTER');
+    // Create a db_or DatabaseCondition where the provided uid matches the node
+    // table uid or the provided uid matches the comment table uid.
     $condition = db_or()
       ->condition("$this->table_alias.uid", $this->value, $this->operator)
-      ->where("0 < (" . (string) $subselect . ")")
-      ->condition(0, $subselect, '<');
-
+      ->condition("comment.uid", $this->value, $this->operator);
+    // Add the join as a relationship to the query.
+    $this->query->add_relationship('comment', $join, $this->table_alias);
+    // Add the condition to the query.
     $this->query->add_where(0, $condition);
   }
 }
-- 
1.7.3.4

