Recreate:
1) Add the "search" block to left side.
2) Set the block to only be visible on <front>.
3) Do a search using the search from your <front> page ---Bug---> the search in empty....

Search does work is you also include the search/* in the block visibility. But I'm exactly trying to not have the search form repeated on the left side since it already appears on the search page.

Thanks,
Chris
PS: Don't think this data is necessary but I also have "advanced search" disabled for anonymous.

Comments

traxer’s picture

Version: 5.1 » 5.5

Confirmed in Drupal 5.5, regardless of the region the block is in. The search field mentioned on admin/build/themes/settings does not show faulty behavior.

mercmobily’s picture

Hi,

This in intriguing.

I can have a look if nobody else is.
(If somebody is already onto it, I won't replicate the efforts)

Bye,

Merc.

mercmobily’s picture

Hi,

First step...

For any future developer should I fail miserably.
In the "faulty" form, this is never true:

function search_view() {
$type = arg(1);

// Search form submits with POST but redirects to GET. This way we can keep
// the search query URL clean as a whistle:
// search/type/keyword+keyword
if (!isset($_POST['form_id'])) {
/* THE FAULTY FORM WILL NEVER EVER GET HERE*/

I am trying to backtrack the problem, and see WHERE the two forms behave differently code-wise.

Merc.

mercmobily’s picture

Hi,

Update #2:

The "actual" problem is that for the "faulty" form the submit hook is never called. Therefore, redirection doesn't happen at all.

search_form_submit() never happens. I am not familiar with the internals of how the submit hooks is actually called. I might have to "get familiar" right now. However, I don't have much time left.

Merc.

mercmobily’s picture

Hi,

Short update: in form.inc, something's wrong with the faulty form:

function drupal_submit_form($form_id, $form) {
global $form_values;
$default_args = array($form_id, &$form_values);
$submitted = FALSE;
$goto = NULL;

if (isset($form['#submit'])) { <--- This is never true

If course, it ought to be.

Trying to backtrace the problem from here.

Merc.

mercmobily’s picture

Hi,

Alright, this is gonna be "it" as far as my investigation... hopefully somebody with a deeper understanding of how forms work in Drupal will find this info useful.

Basically, when is set, the function drupal_process_form() appears to be called only once. The $form_id is 'search_form', whereas _POST['form_id'] is 'search_block_form' - they are not the same, and therefore this ends up being false:

if (($form['#programmed']) || (!empty($_POST) && (($_POST['form_id'] == $form_id)))) {

HOWEVER, if is not set drupal_process_form() is then called _again_, and this time $form_id is correct: it's 'search_block_form'. Therefore, the if above works and the form is actually processed.

I tried and tried to figure out why on earth drupal_process_form() is called again, but I don't know Drupal forms well enough to figure this out.

I hope this will help...

Merc.

robertdouglass’s picture

Title: Search does not work in this instance... » Search block broken

better title.

mercmobily’s picture

Hi,

I have the feeling robertDouglass is about to show how little I know about Drupal by fixing this in 11 minutes.
I can only hope my little analysis helps, even a little bit.

Merc.

robertdouglass’s picture

@mercmobily: actually, I'm sorting through all search related issues making sure they have good titles, the right status, and are relevant, so that they get the attention they need. I haven't looked at this one in depth.

Anonymous’s picture

The problem seems to be that the block and theme search forms rely on re-submitting the form at the search/node path. If the form is disabled on that page, the values won't get passed back to the path so the search can actually be done.

I suspect the reason the theme search form doesn't have this problem is because if you're using the theme search form, you're probably displaying it on every page because it's part of your page.tpl.php.

The easy solution is to use CSS to hide the search form on your search pages. You could either do this by overriding the theme function:

function phptemplate_search_block_form($form) {
  if (arg(0) == 'search') {
    return '<div class="container-inline" style="display: none;">'. drupal_render($form) .'</div>';
  }
  else {
    return '<div class="container-inline">'. drupal_render($form) .'</div>';
  }
}

or by using a CSS rule that selects based on a property of the page (see Zen's phptemplate_page function for an example in Drupal 5).

jhodgdon’s picture

Version: 5.5 » 7.x-dev

I think the search code is doing the same kind of redirect in Drupal 7, so this could still be an issue? Moving to D7 temporarily at least until someone investigates. If it's not a D7 bug, then we need to see if it's D6. If not that, move back to D5 for fixing.

jhodgdon’s picture

Version: 7.x-dev » 5.x-dev

Following the steps given in the original issue report...

a) I just tested this in Drupal 7. It is not a bug there. When you get to the search page, you have your search term (no search block visible) and the search results are there.

b) Same for Drupal 6.

I don't have a Drupal 5 test box set up at the moment, but I'll put this down to Drupal 5.x for testing/verification/fixing.

jhodgdon’s picture

Status: Active » Closed (won't fix)

7.0 is out tomorrow, 5.x is obsolete, won't fix, sorry.