Hi,
When you /search/site/something_that_has_no_results, I get:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1: SELECT u.uid AS uid, u.name AS name FROM {users} u WHERE (uid IN ()) ; Array ( ) in facetapi_map_author() (line 32 of /www/htdocs/sites/all/modules/contrib/facetapi/facetapi.callbacks.inc).
/**
* Map callback for node authors.
*/
function facetapi_map_author(array $values) {
$result = db_select('users', 'u')
->fields('u', array('uid', 'name'))
->condition('uid', $values, 'IN')
->execute();
debug shows an empty array, unlike when you have some results, in which case it is an array of user I.D.'s
Comments
Comment #1
cpliakas commentedHi SangersDrupalDude.
Thanks for the post. This is actually a regression introduced by the resolution to issue #1356962: Current Search block displays incorrect values when there are no search results which may effect more than just the author mapping callback. The old logic mapped values only when there were items in the render array, therefore when a search had no results there were no values to map. This logic was flawed and we moved the mapping functionality above the line checking whether there are items in the render array, and as a side effect there is now the possibility of passing an empty array to the mapping callback. Changing the title to reflect this information.
I think the solution here is to add a condition to the FacetapiFacetProcessor::mapValues() method testing whether the
$valuesvariable is empty prior to invoking the callbacks. Specifically, anif ($values = array_unique(array_keys($build + $this->getActiveItems()))) {should do the trick.Placing this on the "low hanging fruit" list. Still looking for committer #20! Great way to get on the list.
Thanks,
Chris
Comment #2
cpliakas commentedMoving back to a 7.x-1.x task.
Comment #3
chrisyates commentedPatch for issue.
Comment #4
cpliakas commentedThis looks great. Marking as RTBC.
Comment #5
cpliakas commentedCommitted at http://drupalcode.org/project/facetapi.git/commit/46473fd.
Congrats on becoming the 20th code contributor to Facet API!