Very Very Weird php object behavior
| Project: | Faceted Search |
| Version: | 6.x-1.0-beta2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Ok, I don't believe this issue is the fault of faceted search code, but it appeared in the module's code so I figured I'd throw it out there and see if you have any ideas about it.
The thing that prompted this wild ride through the faceted search code was an error where authenticated users could search just fine, but anonymous users could not search for more than one term. So, any anonymous search of the form "term1 term2" or "term1 + term2" etc., would cause a white screen of death. The first thing I did, of course, was check out the apache logs for a php error. What I saw was that everytime this particular WSOD occurred there was a Segmentation Fault. Also, I could see from the HTTP Headers that the server was just dying and not returning a 500 or anything like that.
So I start diving into the code and var_dumping my heart out and eventually backtraced my way to the _faceted_search_compare_filters() function used in one of the uasorts of the $filters array. In this function if the $a_cat and $b_cat weights are the same, it tries to do a strcmp on the labels like so:
if ($a_cat->get_weight() == $b_cat->get_weight()) {
return strcmp($a_cat->get_label(), $b_cat->get_label());
}My first thought was that php was fubar and strcmp was failing, but more var_dumping concluded that the calls to get_label() were failing. So I looked at that function and saw that it's logic was sound, I could print the proper labels just fine, but if I returned anything, php died. I even tried manually returning various strings and bools and php always died. Somehow, php could not return from the call to get_label(). A debug_backtrace() seems to indicate that it knows how it got there, so I am really at a loss as to why it can't return.
My current hacky fix is to skip the call to get_label() like so:
if ($a_cat->get_weight() == $b_cat->get_weight()) {
$temp_a = $a_cat->check_label(theme('faceted_search_keyword_and_label', $a_cat->_word), FALSE);
$temp_b = $b_cat->check_label(theme('faceted_search_keyword_and_label', $b_cat->_word), FALSE);
return strcmp($temp_a, $temp_b);
//return strcmp($a_cat->get_label(), $b_cat->get_label());
}This causes the search functionality to behave as normal.
So, if any php object wizards have some insight, please share with us.
Thanks
