Searching merged tickets yields missing results

This is definitely a bug… I’m hoping someone can help narrow down where/how to fix it. I have three tickets in question. 1269, 1270, and 1271. 1269 and 1270 have been merged. 1271 talks about 1269 and 1270. The original content of 1269 was simply ‘testcandidate1’ and 1270 was ‘testcandidate2’. If I search for content like ‘testcandidate2’ I get no results. I opened 1271 for myself to resolve this bug which contains ‘testcandidate2’ in it as well, so searches now show just ticket 1271. The problem is that the SQL string is limiting to tickets.id = tickets.effectiveid, which will strip out all merged tickets. d’oh! Here’s a simple command line script and its debug output:

[snip]
my $tickets = new RT::Tickets($RT::SystemUser);
$tickets->LimitContent(VALUE => ‘testcandidate2’, OPERATOR => ‘LIKE’);
$tickets->DEBUG(1);
while (my $Ticket = $tickets->Next) {
print $Ticket->id . “\n”;
}
[snip]

RT::Tickets=HASH(0x86034d0)->_GenericRestriction QualifiedField=Attachments_2.Content
RT::Tickets=HASH(0x86034d0)->_GenericRestriction QualifiedField=main.EffectiveId
RT::Tickets=HASH(0x86034d0)->_GenericRestriction QualifiedField=main.Type
DBIx::SearchBuilder->DoSearch Query: SELECT DISTINCT main.* FROM Tickets main, Transactions Transactions_1, Attachments Attachments_2 WHERE ((main.EffectiveId = main.id)) AND ((main.Type = ‘ticket’)) AND ( ( ( (Attachments_2.Content LIKE ‘%testcandidate2%’) ) ) ) AND Attachments_2.TransactionId = Transactions_1.id AND main.id = Transactions_1.Ticket
ID is 1271
1271

If i manually remove the ‘main.EffectiveId = main.id’ part of the WHERE clause, both 1270 and 1271 show up like they ‘should’ (though perhaps it should report 1269 instead of 1270 since 1269’s the ‘real’ ticket number now.
Any ideas on how to fix this?

Thanks!

-=| Ben

This is definitely a bug… I’m hoping someone can help narrow down where/how to fix it. I have three tickets in question. 1269, 1270, and 1271. 1269 and 1270 have been merged. 1271 talks about 1269 and 1270. The original content of 1269 was simply ‘testcandidate1’ and 1270 was ‘testcandidate2’. If I search for content like ‘testcandidate2’ I get no results. I opened 1271 for myself to resolve this bug which contains ‘testcandidate2’ in it as well, so searches now show just ticket 1271. The problem is that the SQL string is limiting to tickets.id = tickets.effectiveid, which will strip out all merged tickets. d’oh!

Merged tickets should never show up in search results, only the tickets
that they were merged into. does 1269 not have its id == its
EffectiveId?

Request Tracker... So much more than a help desk — Best Practical Solutions – Trouble Ticketing. Free.

Merged tickets should never show up in search results, only the tickets
that they were merged into. does 1269 not have its id == its
EffectiveId?

The contents should cause a search match and result in the ‘real’ ticket
number being displayed, but it doesn’t; 1269 should show up in the list of
tickets when I perform my search. 1269’s EID is 1269, and 1270’s is 1269.

-=| Ben

For now, I’ve commented out the following code in
lib/RT/Tickets_Overlay_SQL.pm

We only want to look at EffectiveId’s (mostly) for these searches.

unless (exists $self->{_sql_looking_at}{‘effectiveid’}) {
$self->SUPER::Limit( FIELD => ‘EffectiveId’,
ENTRYAGGREGATOR => ‘AND’,
OPERATOR => ‘=’,
QUOTEVALUE => 0,
VALUE => ‘main.id’
); #TODO, we shouldn’t be hard #coding the tablename to main.
}

I realize two problems this will create, which I can live with for now
(recalling tickets 1269 and 1270, 1269 contains ‘testcandidate1’ and 1270
contains ‘testcandidate2’ and 1270 was merged into 1269)

  1. Searching for ‘testcandidate2’ will result in link to ticket 1270 instead
    of 1269
  2. Search results will contain duplicate ticket numbers (well, they’ll show
    as different numbers, but they point at the same effective ticket) if a
    match is found across multiple tickets that are now merged

I’m not sure of the proper way to solve this problem.

-=| Ben----- Original Message ----- 

From: “Ben Goodwin” ben@atomicmatrix.net
To: rt-users@lists.bestpractical.com
Sent: Thursday, January 01, 2004 8:46 PM
Subject: Re: [rt-users] Searching merged tickets yields missing results

Merged tickets should never show up in search results, only the tickets
that they were merged into. does 1269 not have its id == its
EffectiveId?

The contents should cause a search match and result in the ‘real’ ticket
number being displayed, but it doesn’t; 1269 should show up in the list of
tickets when I perform my search. 1269’s EID is 1269, and 1270’s is 1269.

-=| Ben