warning: Invalid argument supplied for foreach()..on line 1190.
stevepurkiss - October 18, 2009 - 20:36
| Project: | Apache Solr Search Integration |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
I'm using the dev version and always get this error message on any search:
warning: Invalid argument supplied for foreach() in /my/directory/structure/httpdocs/sites/all/modules/apachesolr/apachesolr.module on line 1190.
It's fine on the rc1 version but loving the CCK fields being indexed hence using dev

#1
CCK fields can be indexed using the 6.x-1.0 branch. Anyway, here is a quick band-aid fix for the problem.
#2
best to follow coding standards and indent.
#3
Looks ok for 6.2.
#4
Let's confirm it's not an issue in the other branches.
#5
I'm a little bit confused. 6.x-2.x shows that $params['fq'] is a 2 level nested array.
<?php$params['fq'][$delta][] = $value;
?>
But in 5.x-2.x (6.x-1.x) seems to be only a 1 level deep. In apachesolr_search.module is handled:
<?phpif (('' == $keys) && isset($params['fq'])) {
// Move the fq params to the q.alt for better performance.
$params['q.alt'] = implode(' ', $params['fq']);
unset($params['fq']);
}
?>
Digging a little bit in 6.x-2.x-dev I found that next part is missed in
apachesolr_modify_query()from 6.x-1.x and 5.x-2.x which seems to be critical on subqueries....<?phpif ($filter_queries = $params['fq']) {
foreach ($filter_queries as $delta => $value) {
$fq = $tag = '';
$op = 'AND';
// CCK facet field block deltas are not the same as their Solr index field names.
$cck_delta = '';
if (strpos($delta, '_cck_')) {
$cck_delta = trim(drupal_substr($delta, 7, drupal_strlen($delta)));
}
if (in_array($delta, $ors) || in_array($cck_delta, $ors)) {
$tag = "{!tag=$delta}";
$op = 'OR';
}
$fq = implode(" $op ", $params['fq'][$delta]);
$params['fq'][] = $tag . $fq;
unset($params['fq'][$delta]);
}
}
?>
This part transform $param['fq'] from a 2 level to an one level array.
Discussion needed...
#6
Ok - that's all related to OR facets. So let's not backport this as it's pretty complicated and disruptive.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.