Have anyone tried that?
When I try to refine by one field, I get 'no results' and strange output in 'current search' block. Check the screenshot

CommentFileSizeAuthor
#5 number-facets-zero-value.patch896 bytesDavid Lesieur
facet_cck.jpg147.48 KBrestyler

Comments

restyler’s picture

The error can be reproduced only when you search by 'off' value of checkbox (For example I have a cck field 'kid friendly', it's a number single on/off checkbox). One node has this checkbox on, and one node has this checkbox off. So when you click on
Kid friendly (1) on search page - it works ok, but if you click on Kid friendly Off (1) - you get the error.

junedkazi’s picture

Priority: Normal » Critical

Hi,

I also came across this same issue. Here are the things which I noticed.
Here are my observations:

For a radio button number field the allowed values are as follows:
0|No
1|Yes

1 - When it comes into function number_facets_cck_facets_collect(&$facets, $field, $domain, $env, $arg = NULL)
in case "text" the if condition if ($number = search_query_extract($arg, $field['field_name'])) breaks down
because if $number is 0 is case of the No(0) case it won't enter the if condition which breaks down the search first.

So I changed the if condition as follows to debug it a bit further

if (is_numeric($number = search_query_extract($arg, $field['field_name'])))

so that it enters the if condition.

Once it enters the if condition it breaks down again at this point

$arg = search_query_insert($arg, $field['field_name']);

so on checking the search module I noticed that it checks for

if (search_query_extract($keys, $option))

This again will break it down bcoz in case of the No(0) case the function
search_query_extract($keys, $option) will return a 0.

so if(0) will always fail .

I am still trying to figure a way out of this situation.

David Lesieur’s picture

David Lesieur’s picture

Status: Fixed » Active
David Lesieur’s picture

Title: error when trying to refine by cck field (integer, single on/off checkbox) » Empty result set when search key value is 0
Status: Active » Fixed
StatusFileSize
new896 bytes

I have committed the patch below to the Number Facets module, but you'll also need to apply the patch from #419388: search_query_insert breaks down when the value of key is 0 to get the problem solved.

Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.