Hi list,

I'm currently investigating an issue and I think I found a bug. I'm not
experienced enough in Perl to know for sure I'm right.

Can someone please confirm that I identified the cause of the problem
correctly and, if so, adivce on what I should do next? Post in bugs.otrs.org
?

Version: v3.1.10

Symptoms:
- For some companies, the open ticket count is wrong when shown in
AgentTicketZoom, Customer Information "widget". This information appears
with a small icon and the text "Open tickets (#)", at the bottom of the
aforementioned widget. # is supposed to show the number of tickets opened
for current ticket's CustomerID (I know OTRS can also filter by ticket's
customer user but I haven't enabled this).

Investigation:
- I enabled query logging on MySQL and saw that the value passed on the
WHERE condition for CustomerID was wrong. This particular CustomerID
contains multiple consecutive spaces. Instead of the correct value ("some
company  name - 12345"; notice it contains double spaces between the first
three words) the WHERE condition had a faulty value, with the double spaces
replaced with a single space ("some company name - 12345"). The result was
0 instead of the correct ticket count.

- I saw in OTRS's sources that the faulty count is computed through a call
to Kernel::System::TicketSearch > TicketSearch(), made from
Kernel::Output::HTML::CustomerUserGenericTicket > Run()

- In Kernel::System::TicketSearch > TicketSearch(), CustomerID's entry in
WHERE is computed in a loop by calling Kernel::System::DB >
QueryCondition(). In QueryCondition(), the value for the condition is
processed by this code:

# remove double spaces
$Param{Value} =~ s/\s+/ /g;

- At this point I strongly suspect this is the root cause of the problem.
The value that gets injected in the SQL string's WHERE clause for
CustomerID seems to go through a step that removes double spaces from this
value that should've otherwise be used literally.

- Obviously, the problem is not limited to just my scenario. TicketSearch
is called from many other places and the WHERE clause for other ticket
attributes is processed in the same way, with "Title" being the most likely
to cause a similar problem in other places.

- Simply declaring that CustomerID doesn't support double spaces would be a
very bad "solution" because I need to integrate with other systems
(non-OTRS) and can't dictate what the CustomerID should be.

/bogdan
_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev

Reply via email to