[Vtigercrm-commits] [vtiger development] #7655: Filter on Last Modified By causes unhandled database errors
vtiger development
vtiger-tickets at trac.vtiger.com
Mon Mar 4 23:34:06 PST 2013
#7655: Filter on Last Modified By causes unhandled database errors
------------------------+---------------------------------------------------
Reporter: david | Owner: developer
Type: defect | Status: new
Priority: unassigned | Milestone: Unassigned
Component: vtigercrm | Version: 5.4.0
Severity: Medium | Keywords:
------------------------+---------------------------------------------------
A filter or advanced search on "Last Modified By" will generate a bad
query if no columns from the vtiger_users are included in the results. For
an advanced search this results in "undefined" search results. For a
fitler:
* The search, filters, list view and paging panels are replaced with the
text "undefined".
* A !JavaScript Alert message saying "undefined" appears.
* The page remains broken until you log off due to the filter being
remembered.
* It is not possible to edit or delete the filter directly because
selecting it instantly breaks the page. The only option seems to be going
to the edit page for another filter and and changing the ID in the query
string (this can be done to delete the broken filter too).
The client-side breakage is caused by a lack of error checking in
[source:vtigercrm/branches/5.4.0/include/js/ListView.js ListView.js]. In
particular the code on
[source:vtigercrm/branches/5.4.0/include/js/ListView.js at 13759#L391 line
391] assumes the request will always be successful. In this case it is not
resulting in the alert box and the "undefined" page contents. I see
similar code in four other places in this file which are probably capable
of failing in similar ways.
In this particular case the server has responded with a 500 error due to a
bad query being generated. The query generated was:
{{{
SELECT count(*) AS count
FROM vtiger_contactdetails
INNER JOIN vtiger_crmentity ON vtiger_contactdetails.contactid =
vtiger_crmentity.crmid
LEFT JOIN vtiger_users ON vtiger_crmentity.modifiedby = vtiger_users.id
WHERE vtiger_crmentity.deleted=0
AND ( (( trim(CONCAT(vtiger_users2.first_name,'
',vtiger_users2.last_name)) = 'foo') ))
AND vtiger_contactdetails.contactid
}}}
The WHERE condition for the "Last Modified By" filter is assuming the join
to vtiger_users was aliased as "vtiger_users2" resulting in the following
error from MySQL:
{{{
[1054]Unknown column 'vtiger_users2.first_name' in 'where clause'
}}}
I believe this is being done on
[source:vtigercrm/branches/5.4.0/include/QueryGenerator/QueryGenerator.php at 13759#L522
line 522 of QueryGenerator.php]. I'm not sure what the code there is
trying to achieve so I'm not really willing to try and fix it myself
(don't want to find out a few months down the line my fix has broken
something else).
As a work around at the moment you can include any column from the
vtiger_users table to the result set for the filter. This causes a second
join to be added. The join for the where clause (as it is added last) gets
aliased to vtiger_users2 making the query work. This isn't ideal however
as the user gets no indication of why the filter has broken and has no way
of editing it.
--
Ticket URL: <http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7655>
vtiger development <http://trac.vtiger.com/>
vtiger CRM
More information about the vtigercrm-commits
mailing list