apachesolr_search_view() checks if there are any POST data and only performs a search if the form is submitted. This has problems with modules that redirect to search pages. I encountered this when testing solr + ubercart search results integration (Add to cart button).

rDouglass suggested that this might be removed - posting a patch.

CommentFileSizeAuthor
apachesolr_post.patch3.02 KBmeba

Comments

pwolanin’s picture

Status: Needs review » Needs work

This doesn't look quite right.

the POST check is there to avoid running the search twice when the form is submitted. Perhaps the check can be more specific?

Scott Reynolds’s picture

the POST check is there to avoid running the search twice when the form is submitted.

Then can it use apachesolr_has_searched() instead ?

meba’s picture

has_searched() wouldn't work because the two searches happen in 2 requests (the static variable is lost).

1) Form is submitted, menu callback calls _view() function.
2) _submit() is called, redirect to apachesolr_search/$terms is performed
3) Menu callback calls _view() function.

The only solution I came up with so far is:

 if (!in_array($_POST['form_id'], array('search_form', 'search_block_form'))) {

This ensures the search is not performed when you submit a search form. (I am solving this for Ubercart integration - add to cart button doesn't work if the previous check is there, callback function is not called).

Disadvantage: What if somebody creates his own search form?

pwolanin’s picture

I suppose one could define a variable listing form IDs. Not sure if there is a really clean solution here - the approach above looks reasaonble.

pwolanin’s picture

Status: Needs work » Fixed

Robert committed a different fix here: #614644: Forms attached to Apachesolr search results won't work

follow up there or open a new issue.

Status: Fixed » Closed (fixed)

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