error handling
Suuch - June 30, 2006 - 00:02
| Project: | Light CRM |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Just run into this error:
Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT u.mail, u.name FROM users u LEFT JOIN users_roles ur on u.uid = ur.uid WHERE
Which is caused by an exception to the following code in the function lightcrm_comment(). The exception in my case was that I hadn't set any roles so $roles=array(), an empty array.
$roles = variable_get('lightcrm_mailroles', array());
foreach ($roles as $role_k => $role_v) {
if ( $role_v > 0 ) {
if ( $role_where ) {
$role_where .= ' OR ';
}
if ( $role_v == DRUPAL_AUTHENTICATED_RID ) {
$role_where = '1';
} else {
$role_where = 'ur.rid = '. $role_v;
}
}
}A possible fix:
1. check if $roles is empty. If not proceed, else
2. set a drupal error message that notifies the admin user that no roles have been setup to receive lightcrm emails but nonetheless accept the user's comment/support request.

#1
Thanks Suuch. It took me a while to figure out why that error message was popping up. I'll look at a way to add the error cheking you suggest.