On my site search function was totally broken after upgrade to 6-1.7 (it was OK with 6-1.6).

The redirection urls generated by custom search were wrong and looked like "http://mysite.com/http://mysite.com/search/node/bla-bla-bla", so site address was added twice.

I found the cause in line 386 of custom_search.module:

 $base_redirect = 'http' . ((isset($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . url();

For my setup, this problem was fixed by changing url() to base_path(). So the line above now looks as follows:

 $base_redirect = 'http' . ((isset($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT'] == 443) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . base_path();

Comments

jdanthinne’s picture

Unfortunately, base_path doesn't include the language in multilingual sites.
I've made some research and came up with something simpler I think.
Can you try with:

<?php $base_redirect = $base_url . $language->language; ?>
gleich’s picture

It won't work for me, cause my site is multilanguage and I use domain prefixes for language variants (i.e. en.mysite,com).

I wonder if there could be a solution that covers all multilanguage setups?

jdanthinne’s picture

What is the generated url when using #1?

gleich’s picture

Hm, sorry, #1 seems to be OK as well, though I get an extra slash like this:

http://ru.saveoldkyiv.org//search/node/hh

jdanthinne’s picture

What if you add this line just after:

<?php
if (substr($base_redirect, -2) == '//') $base_redirect = substr($base_redirect, 0, -1);
?>
gleich’s picture

#5 has no effect (when placed just after line mentioned in #1).

But the next line which is already there seems to cause the problem:

if (drupal_substr($base_redirect, -1) != '/') $base_redirect .= '/';

If I comment it out, I get only one slash. But this line looks quite normal.
Weird...

jdanthinne’s picture

Oh, I had removed this line in fact in my tests, forgot to tell you (and you can download the latest DEV version, the line was removed).
So #1 should be finally ok with the line (#6) removed? Download latest DEV and confirm please.

gleich’s picture

Yes, with latest DEV all works as it should.

Thanks for the prompt responses!

jdanthinne’s picture

Status: Active » Fixed
jon nunan’s picture

Status: Fixed » Active

Not sure if this is the right place, but the 7 dev seems broken if you aren't using locale prefixes. Instead of
http://{BASE}/search/node/{SEARCH STRING}
I get
http://{BASE}/en/search/node/{SEARCH STRING}
which will give me a 404.

Looking at the code I see

<?php
$base_redirect = $GLOBALS['base_url'] . '/' . $GLOBALS['language']->language;
?>

I think you should be using 'prefix' here, as the language is set even when you're not using the path prefix. So something more like:

<?php
$base_redirect = $GLOBALS['base_url'] . '/' . $GLOBALS['language']->prefix;
?>
jdanthinne’s picture

Status: Active » Fixed

@meatstack: thanks, pushed the changes to DEV version.

Status: Fixed » Closed (fixed)

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