Commit aebd9ea2 authored by David Lesieur's avatar David Lesieur

Fixed handling of empty/null values.

parent eef1e4ae
......@@ -116,6 +116,14 @@ class cck_facet extends faceted_search_facet {
$query->add_table($db_info['table'], 'vid', 'n', 'vid');
$main_column = array_shift($db_info['columns']);
$query->add_field($db_info['table'], $main_column['column'], $this->_field['field_name']);
if ($main_column['type'] == 'longtext' || $main_column['type'] == 'varchar') {
// Reject empty text.
$query->add_where($db_info['table'] .'.'. $main_column['column'] ." != ''");
}
else {
// Reject null value.
$query->add_where($db_info['table'] .'.'. $main_column['column'] ." IS NOT NULL");
}
$query->add_groupby($this->_field['field_name']);
return TRUE;
}
......
......@@ -36,8 +36,11 @@ function number_facets_cck_facets_collect(&$facets, $field, $domain, $env_id, $a
if (isset($arg->{$field['field_name']}) && is_array($arg->{$field['field_name']})) {
// Iterate through the field's multiple values.
foreach ($arg->{$field['field_name']} as $item) {
$category = new cck_facet_category($field, array_shift($item));
$facets[] = new cck_facet($field, array($category));
$value = array_shift($item);
if (is_numeric($value)) {
$category = new cck_facet_category($field, $value);
$facets[] = new cck_facet($field, array($category));
}
}
}
break;
......
......@@ -37,8 +37,11 @@ function text_facets_cck_facets_collect(&$facets, $field, $domain, $env_id, $arg
if (isset($arg->{$field['field_name']}) && is_array($arg->{$field['field_name']})) {
// Iterate through the field's multiple values.
foreach ($arg->{$field['field_name']} as $item) {
$category = new cck_facet_category($field, array_shift($item));
$facets[] = new text_facet($field, array($category));
$value = array_shift($item);
if ($value != '') {
$category = new cck_facet_category($field, $value);
$facets[] = new text_facet($field, array($category));
}
}
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment