diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm index 7718e619183..260a646d464 100644 --- a/lib/RT/Interface/Web.pm +++ b/lib/RT/Interface/Web.pm @@ -5806,11 +5806,16 @@ sub PreprocessTransactionSearchQuery { my @limits; if ( $args{ObjectType} eq 'RT::Ticket' ) { - @limits = ( - q{TicketType = 'ticket'}, - qq{ObjectType = '$args{ObjectType}'}, - $args{Query} =~ /^\s*\(.*\)$/ ? $args{Query} : "($args{Query})" - ); + if ( $args{Query} !~ /^TicketType = 'ticket' AND ObjectType = '$args{ObjectType}' AND (.+)/ ) { + @limits = ( + q{TicketType = 'ticket'}, + qq{ObjectType = '$args{ObjectType}'}, + $args{Query} =~ /^\s*\(.*\)$/ ? $args{Query} : "($args{Query})" + ); + } + else { + @limits = $args{Query}; + } } else { # Other ObjectTypes are not supported for now diff --git a/t/web/search_txns.t b/t/web/search_txns.t index bf4ca0b817f..24366e19117 100644 --- a/t/web/search_txns.t +++ b/t/web/search_txns.t @@ -29,9 +29,14 @@ diag "Query builder"; $m->follow_link_ok( { id => 'page-results' } ); $m->title_is('Found 3 transactions'); + $m->get_ok($m->uri . '&RowsPerPage=1'); + $m->follow_link_ok( { text => '2' } ); + $m->follow_link_ok( { text => '3' } ); + + $m->follow_link_ok( { text => 'Edit Search' }, 'Build Query' ); + my $form = $m->form_name('BuildQuery'); + is($form->find_input('Query')->value, qq{TicketType = 'ticket' AND ObjectType = 'RT::Ticket' AND ( TicketId = 1 )}); - $m->back; - $m->form_name('BuildQuery'); $m->field( TypeOp => '=' ); $m->field( ValueOfType => 'Create' ); $m->click('AddClause');