I created a search page with a custom filter that includes 2 fq values. If I track the fq values through the code, it looks like these 2 values are duplicated (2 becomes 4) in addParam(). More specifically, the duplication seems to be introduced only when fq is an array and it looks like the culprit is array_walk_recursive() on line 454.

// We never actually populate $this->params['fq'].  Instead
// we manage everything via the filter methods.
if ($name == 'fq') {
  if (is_array($value)) {
    array_walk_recursive($value, array($this, 'addFq'));
    return $this;
  }
  else {
    return $this->addFq($value);
  }
}

My query ends up with 4 filters but only 2 of them are unique. Has anyone else run into this?

Comments

nick_vh’s picture

Status: Active » Closed (cannot reproduce)
StatusFileSize
new99.95 KB

hmm, I can't replicate this
Search | Smartphone compare-2.jpg

As you can see I am adding two params to the url, and it returns two in my conditions array? I even checked what he is sending to solr, and no oddnesses there. Please post a follow-up with clear instructions on how to reproduce. Closing it for now, for the sake of a clean issue queue.

cappadona’s picture

Status: Closed (cannot reproduce) » Active
StatusFileSize
new158.92 KB

Thanks Nick. Sorry for not being clearer in my original post.

I also see 2 params in my conditions array at line 25 of apachesolr_search.pages.inc. But follow the trail a little further and I find that this array is eventually doubled before the query is sent to Solr.

a. Check the params on line 455 of Solr_Base_Query.php (within addParam())
b. Check the params on line 1001 of apachesolr_search.module (within apachesolr_search_run())

Notice that the first time you hit addParam() -- via apachesolr_search_custom_page() -> apachesolr_search_search_results() -> apachesolr_search_run() -> apachesolr_search_add_spellcheck_params() -- we see the fq param is an array of 2, but the second time we hit it -- via apachesolr_search_custom_page() -> apachesolr_search_search_results() -> apachesolr_search_run() -> addParams() -- we see the fq param is an array of 4.

dpm output for addParam fq doubling

I've attached a screenshot to help illustrate this but I'm still probably not describing this very clearly so please let me know if you want me to give it another shot.

Thanks.
- Nick

nick_vh’s picture

StatusFileSize
new467 bytes

I was able to replicate indeed. Not sure how that even got in there. Have to review other usecases, but afaik this fixes it. It did the addParam twice, once in the solr query class constructor and once in that function.

nick_vh’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Active » Patch (to be ported)

Committed to D7, thanks! I checked the workflow and this is completely ok. It did the addParam twice. Thank you for this incredible stupid bug! :)

killua99’s picture

StatusFileSize
new469 bytes

Ported :O can't change the status issue.

killua99’s picture

Status: Patch (to be ported) » Needs review

Now I can ... o.O

nick_vh’s picture

Status: Needs review » Fixed

committed, thanks!

cappadona’s picture

Thanks Nick. Looking good on my end.

pwolanin’s picture

Thanks - though we should dig in later to see whether the query class should have caught & ignored the duplication

Status: Fixed » Closed (fixed)

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