[rt-users] content search is a problem

Kevin Murphy murphy at genome.chop.edu
Fri Oct 27 11:40:38 EDT 2006


Here's a patch I use to prevent content searches from searching named 
attachments (uploaded files).  This patch is to 3.6.1, but I haven't 
tested it much.

I create a modified version of $RTHOME/lib/RT/Tickets_Overlay.pm in 
$RTHOME/local/lib/RT/.

This patch is contingent on a configuration variable, so the following 
has to be added to RT_SiteConfig.pm:

# If $DontSearchFileAttachments is set to a true value, then 
named                                                                         

# attached files are not searched.  Although this is usually 
what                                                                          

# users expect, it is not the 
default.                                                                                                     


Set($DontSearchFileAttachments, 'true');

Here's the patch:

--- old/Tickets_Overlay.pm      2006-07-18 17:51:35.000000000 -0400
+++ new/Tickets_Overlay.pm      2006-10-23 20:14:39.000000000 -0400
@@ -679,14 +679,36 @@
     $self->_OpenParen;
 
     #Search for the right field
-    $self->_SQLLimit(
-        ALIAS         => $self->{_sql_trattachalias},
-        FIELD         => $field,
-        OPERATOR      => $op,
-        VALUE         => $value,
-        CASESENSITIVE => 0,
-        @rest
-    );
+    if ($field eq 'Content' and $RT::DontSearchFileAttachments) {
+       $self->_SQLLimit(
+                       ALIAS         => $self->{_sql_trattachalias},
+                       FIELD         => 'Filename',
+                       OPERATOR      => 'IS',
+                       VALUE         => 'NULL',
+                       SUBCLAUSE     => 'contentquery',
+                       ENTRYAGGREGATOR => 'AND',
+                      );
+       $self->_SQLLimit(
+                       ALIAS         => $self->{_sql_trattachalias},
+                       FIELD         => $field,
+                       OPERATOR      => $op,
+                       VALUE         => $value,
+                       CASESENSITIVE => 0,
+                       @rest,
+                       ENTRYAGGREGATOR => 'AND',
+                       SUBCLAUSE     => 'contentquery',
+                      );
+    } else {
+       $self->_SQLLimit(
+                       ALIAS         => $self->{_sql_trattachalias},
+                       FIELD         => $field,
+                       OPERATOR      => $op,
+                       VALUE         => $value,
+                       CASESENSITIVE => 0,
+                       ENTRYAGGREGATOR => 'AND',
+                       @rest
+                      );
+    }
 
     $self->_SQLJoin(
         ALIAS1 => $self->{_sql_trattachalias},




More information about the RT-Users mailing list