Ok - I now found out that
1. this bug already has been reported at bugs.sugarcrm.com and is scheduled to be fixed in 4.5.1
2. I nevertheless made a temporary bugfix for the time being that is working for me. Here is the lines I added to include/SearchForm/SearchForm.php (the few lines beteen the two comment // bugfix and // end bugfix).
That fix is far from being perfect, but it seems to work ok for me (until the official fix is out). Especially it would work wrong, if one of the search words (the dropdown values) is a substring of another one. Then the bigger one would be matched even if searched for the smaller one. But this is not the case in our setup.
Maybe this patch has sideeffects, but I didn't notice one. And since it is "only" searching, it cannot be harmful.
Regards,
Martin
PHP Code:
if($type == 'date') {
// Collin - Have mysql as first because it's usually the case
// The regular expression check is to circumvent special case YYYY-MM
if($GLOBALS['db']->dbType == 'mysql') {
if(preg_match('/^\d{4}.\d{1,2}$/', $field_value) == 0) {
$field_value = $timedate->to_db_date($field_value, false);
$operator = '=';
} else {
$operator = 'db_date';
}
} else if($GLOBALS['db']->dbType == 'oci8') {
if(preg_match('/^\d{4}.\d{1,2}$/', $field_value) == 0) {
$field_value = $timedate->to_db_date($field_value, false);
$field_value = "to_date('" . $field_value . "', 'YYYY-MM-DD hh24:mi:ss')";
}
$operator = 'db_date';
} else if($GLOBALS['db']->dbType == 'mssql') {
if(preg_match('/^\d{4}.\d{1,2}$/', $field_value) == 0) {
$field_value = "Convert(DateTime, '".$timedate->to_db_date($field_value, false)."')";
}
$operator = 'db_date';
} else {
$field_value = $timedate->to_db_date($field_value, false);
$operation = '=';
}
}
if($GLOBALS['db']->dbType == 'oci8' && isset($parms['query_type']) && $parms['query_type'] == 'case_insensitive') {
$db_field = 'upper(' . $db_field . ")";
$field_value = strtoupper($field_value);
}
// bugfix, line 260, include/SearchForm/SearchForm.php:
// test for every multi select parameter, if it is a substring of the field:
// build sql of the form:
// locate('term1', FIELD)>0 OR locate('term2', FIELD)>0 ...
if(is_array($parms['value'])) {
foreach($parms['value'] as $key => $val) {
if($val != ' ' and $val != '') {
if(!empty($where)) {
$where .= " OR ";
}
$where .= " locate('" . $GLOBALS['db']->quote($val) . "',$db_field)>0 " ;
}
}
}
// end bugfix: test for every multi select parameter, if it is a substring of the field
$itr++;
if(!empty($where)) {
$where .= " OR ";
}
switch(strtolower($operator)) {
case 'like':
$where .= $db_field . " like '".$field_value.$like_char."'";
break;
case 'in':
$where .= $db_field . " in (".$field_value.')';
break;
case '=':
Bookmarks