Slight performance increase for common parameter calls to append_sid() (Bug #37555 - Patch by BartVB)

Unsure if this works with the mysterious, uncommented block in front of it, the parsed_urls thingy... whoever wrote it, please prod me. :) Or add comments.

git-svn-id: file:///svn/phpbb/trunk@9151 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2008-12-02 16:27:44 +00:00
parent d054940739
commit eddddaa3a4

View file

@ -2154,6 +2154,33 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
}
}
$params_is_array = is_array($params);
// Get anchor
$anchor = '';
if (strpos($url, '#') !== false)
{
list($url, $anchor) = explode('#', $url, 2);
$anchor = '#' . $anchor;
}
else if (!$params_is_array && strpos($params, '#') !== false)
{
list($params, $anchor) = explode('#', $params, 2);
$anchor = '#' . $anchor;
}
// Handle really simple cases quickly
if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor)
{
if ($params === false)
{
return $url;
}
$url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&' : '&');
return $url . ($params !== false ? $url_delim. $params : '');
}
// Assign sid if session id is not specified
if ($session_id === false)
{
@ -2166,18 +2193,6 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
// Appending custom url parameter?
$append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : '';
$anchor = '';
if (strpos($url, '#') !== false)
{
list($url, $anchor) = explode('#', $url, 2);
$anchor = '#' . $anchor;
}
else if (!is_array($params) && strpos($params, '#') !== false)
{
list($params, $anchor) = explode('#', $params, 2);
$anchor = '#' . $anchor;
}
// Use the short variant if possible ;)
if ($params === false)
{