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

jtsnow - November 5, 2009 - 14:40

CCK fields can be indexed using the 6.x-1.0 branch. Anyway, here is a quick band-aid fix for the problem.

AttachmentSize
apachesolr-module-invalid-arg.patch 901 bytes

#2

Scott Reynolds - November 5, 2009 - 19:39
Status:active» needs work

best to follow coding standards and indent.

#3

robertDouglass - November 6, 2009 - 10:47
Status:needs work» fixed

Looks ok for 6.2.

AttachmentSize
608014.patch 1.04 KB

#4

robertDouglass - November 6, 2009 - 10:49
Version:6.x-2.x-dev» 6.x-1.x-dev
Status:fixed» patch (to be ported)

Let's confirm it's not an issue in the other branches.

#5

claudiu.cristea - November 6, 2009 - 16:19

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:

<?php
 
if (('' == $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....

<?php
 
if ($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

robertDouglass - November 7, 2009 - 14:28
Status:patch (to be ported)» fixed

Ok - that's all related to OR facets. So let's not backport this as it's pretty complicated and disruptive.

#7

System Message - November 21, 2009 - 14:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.