From 7c6b6a783ca2bc3066920704af7f81ca4f4bf6fb 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      |   27 ++++++++++---------
 1 files changed, 14 insertions(+), 13 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..4d77a9d 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($this->table_alias . '.uid', $this->value, $this->operator)
+      ->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

