2 messages in com.mysql.lists.eventum-usersRe: possible bug in using date type f...
FromSent OnAttachments
Sean M. Allin20 Oct 2006 15:59 
Sean M. Allin23 Oct 2006 11:16 
Subject:Re: possible bug in using date type for custom fields that affects advanced searches
From:Sean M. Allin (all@spawar.navy.mil)
Date:10/23/2006 11:16:04 AM
List:com.mysql.lists.eventum-users

Patch for testing advanced searches with custom date fields. Cause was where the custom field is tested to skip the field if the search param is empty. Problem is a date custom field is an array of day,month, and year, so it's never empty. This led to the eventum_issue_custom_field table being added to the query for each custom date field, but never being properly joined.

Sean

--- eventum-20061019/include/class.issue.php 2006-10-23 11:06:25.000000000 -0700 +++ /var/www/html/eventumbeta/include/class.issue.php 2006-10-23 10:50:18.000000000 -0700 @@ -2867,6 +2867,22 @@ if (empty($search_value)) { continue; } + // test is custom field is an array, such as for dates + if(is_array($search_value)) { + $useArray=0; + foreach($search_value as $searchKey=>$searchValue) { + if (empty($searchValue)) { + continue; + } + // set flag to use array custom field in search + $useArray=1; + } + } + // skip using an array custom field if it is empty + if ($useArray==0) { + continue; + } + $field = Custom_Field::getDetails($fld_id); if ($field['fld_type'] == 'multiple') { $search_value = Misc::escapeInteger($search_value);

Think I've found the cause of an ongoing problem where am unable to go to a specific ticket# if an advanced search filter exists, as the query appears to hang the database indefinitely.

I've narrowed it down to the 'date' custom fields. What then happens when trying to view a ticket# is the query adds the eventum_issue_custom_field table once for each date field, but without joining the tables. This is leading to a cartesian product query, in my case trying to query 75,0000^5th power records.

Following is an example of the query where cf13,cf14,cf15,cf16,cf19 are custom date fields. I'm trying to determine if it's a bug, or if I need to set an option value to these fields?

Sean

SELECT iss_id, GREATEST(iss_last_public_action_date, IFNULL(iss_last_internal_action_date, '0000-00-00')) AS last_action_date FROM ( eventum.eventum_issue,eventum.eventum_user, eventum.eventum_issue_custom_field as cf12,eventum.eventum_issue_custom_field as cf13, eventum.eventum_issue_custom_field as cf14,eventum.eventum_issue_custom_field as cf15, eventum.eventum_issue_custom_field as cf16,eventum.eventum_issue_custom_field as cf19 ) LEFT JOIN eventum.eventum_status ON iss_sta_id=sta_id LEFT JOIN eventum.eventum_project_priority ON iss_pri_id=pri_id

WHERE iss_prj_id=2 AND iss_usr_id = usr_id AND (iss_id = cf12.icf_iss_id AND cf12.icf_fld_id = 12 AND cf12.icf_value LIKE '%secure%')

GROUP BY iss_id

ORDER BY iss_pri_id asc, iss_id DESC;