RT 3.4.2 Bug & Patch - Incorrect Custom Field Values in Search Results

[RT 3.4.2]

Found a small bug that showed in the Search results page when searching for
tickets in multiple queues. If a custom field is defined for some but not
all of the search queues, and the custom field column is included in the
results, then for each ticket in a queue where the CF does not appear, the
tickets other CF values are shown.

This patch to Ticket_Overlay.pm seems to fix it. Without the patch, if the
ticket’s queue does not have the CF, $field is null when
SUPER::CustomFieldValues($field) is called and this appears to grab CF
values for all the ticket’s CFs.

Steve

— Ticket_Overlay.pm.orig 2006-02-14 16:50:04.000000000 -0500
+++ Ticket_Overlay.pm 2006-02-14 16:50:32.000000000 -0500
@@ -3659,6 +3659,8 @@
$cf->LoadByNameAndQueue( Name => $field, Queue => ‘0’ );
}
$field = $cf->id;

  •   return RT::ObjectCustomFieldValues->new( $self->CurrentUser )
    
  •       unless $cf->id;
    }
    return $self->SUPER::CustomFieldValues($field);
    
    }

[RT 3.4.2]

Found a small bug that showed in the Search results page when searching for
tickets in multiple queues. If a custom field is defined for some but not
all of the search queues, and the custom field column is included in the
results, then for each ticket in a queue where the CF does not appear, the
tickets other CF values are shown.

This patch to Ticket_Overlay.pm seems to fix it. Without the patch, if the
ticket’s queue does not have the CF, $field is null when
SUPER::CustomFieldValues($field) is called and this appears to grab CF
values for all the ticket’s CFs.

This is the wrong -place to fix this, as I know there are folks using
that behaviour to get exactly what they seem to be asking for. “All
custom field values” for that ticket.

At Tuesday 2/14/2006 05:07 PM, Jesse Vincent wrote:

This is the wrong -place to fix this, as I know there are folks using
that behaviour to get exactly what they seem to be asking for. “All
custom field values” for that ticket.

Ah - how about doing this only if the field argument is supplied?

Thanks,
Steve

At Tuesday 2/14/2006 05:07 PM, Jesse Vincent wrote:

This is the wrong -place to fix this, as I know there are folks using
that behaviour to get exactly what they seem to be asking for. “All
custom field values” for that ticket.

Ah - how about doing this only if the field argument is supplied?

If it’s supplied and comes up empty. That seems reasonable.

At Tuesday 2/14/2006 05:12 PM, Jesse Vincent wrote:>On Tue, Feb 14, 2006 at 05:10:35PM -0500, Stephen Turner wrote:

Ah - how about doing this only if the field argument is supplied?

If it’s supplied and comes up empty. That seems reasonable.

Thanks,
Steve

Here is a revised patch - I’ve explicitly handled the ‘null field arg’
condition up front, as there’s no need to go through the LoadByNameAndQueue
stuff in that case.

Steve

— Ticket_Overlay.pm.orig 2006-02-14 16:50:04.000000000 -0500
+++ Ticket_Overlay.pm 2006-02-15 11:31:06.000000000 -0500
@@ -3652,11 +3652,16 @@
sub CustomFieldValues {
my $self = shift;
my $field = shift;

  • return $self->SUPER::CustomFieldValues() unless $field;
    unless ( $field =~ /^\d+$/ ) {
    my $cf = RT::CustomField->new( $self->CurrentUser );
    $cf->LoadByNameAndQueue( Name => $field, Queue =>
    $self->QueueObj->Id );
    unless ( $cf->id ) {
    $cf->LoadByNameAndQueue( Name => $field, Queue => ‘0’ );
  •       return RT::ObjectCustomFieldValues->new( $self->CurrentUser )
    
  •           unless $cf->id;
        }
        $field = $cf->id;
    }