MyBB Community Forums

Full Version: $refresh_time search waits for 2 seconds before redirecting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

I've just had a look at the time it takes to redirect when performing any search (for instance, selecting "View New Posts").

This always seems to pause for 2 seconds before doing the redirect.
http-equiv="refresh" content="2;URL= ...

I'm trying to really speed things up, and I want to set this to immediate redirect:
http-equiv="refresh" content="0;URL=...

I've seen this defined in online.php as :
$refresh = "<meta http-equiv=\"refresh\" content=\"{$refresh_time}

Which implies $refresh_time is settable, but its not an option in the "Server and Optimization Options" page. Any idea where I can set this (searched the forum for refresh_time, but didn't find anything)
The refresh time in who's online is settable. You can find the setting in Who's Online group settings.
But it will affect to Who's Online page only.
yup, its not the one I was looking for. Seems like the search redirect pause isnt setable from the admin console.

So far this is what I've found:
the file search.php calls a function named redirect:
redirect("search.php?action=results&sid=".$sid, $lang->redirect_searchresults);

The function redirect($url, $message="", $title="") is defined in functions.php

Outside the Who's Online page, I think it's hard coded in the redirect template.
<meta http-equiv="refresh" content="2;URL={$url}" />

If you want to bypass the redirect in search function only, I think you can do that with plugin.
I'll hard code it as 0 seconds, if I can dig it out

further, I've found:

The function run_hooks_by_ref gets called from a class named $plugins
$plugins->run_hooks_by_ref("redirect", $redirect_args);

The class $plugins is defined in a file named class_plugins.php

A bit of understading of OOP is required before digging deeper, I have the JCSP under my belt.. still trailing through this isnt easy

(2010-12-29, 08:01 PM)RateU Wrote: [ -> ]If you want to bypass the redirect in search function only, I think you can do that with plugin.

What do you mean by this, create a plugin to bypass the redirect, if so where do I start?
If you want a plugin for that, you can try this plugin:
http://mybbhacks.zingaburga.com/showthread.php?tid=264
What that plugin seems to do is set the settings['redirects'] = 'no' (if version is 1400)
(this is also defined in the settings.php as $settings['redirects'] = "1"; so it should possibly be defined as "0" here, not "no")

$mybb->settings['redirects'] = ($mybb->version_code >= 1400 ? 0 : 'no');

Interesting to see how this plugging works. In fact, updating settings.php so that $settings['redirects'] = "0"; does actually do the trick... That pointer helped

Cheers ears.
(2010-12-29, 08:36 PM)Tenants Wrote: [ -> ]What that plugin seems to do is set the settings['redirects'] = 'no' (if version is 1400)
(this is also defined in the settings.php as $settings['redirects'] = "1"; so it should possibly be defined as "0" here, not "no")

$mybb->settings['redirects'] = ($mybb->version_code >= 1400 ? 0 : 'no');

It will use "0" if the plugin run in MyBB 1.4 or 1.6. And use "no" if you run MyBB 1.2.
It is needed to keep the compatibility for MyBB 1.2, 1.4 and 1.6.
Ah, I see.. Cheers, setting it to 0 should be fine for 1.4 then