Skip to content

Commit d4662fb

Browse files
Merge pull request #8377 from Sesquipedalian/2.1/sid
[2.1] Replaces uses of deprecated constant SID with calls to session_id()
2 parents 2c0ec23 + 0588000 commit d4662fb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Sources/QueryString.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,14 @@ function ob_sessrewrite($buffer)
648648
{
649649
global $scripturl, $modSettings, $context;
650650

651-
// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
652-
if ($scripturl == '' || !defined('SID'))
651+
// If $scripturl is set to nothing, or the session ID is not defined (SSI?) just quit.
652+
if ($scripturl == '' || session_id() === false)
653653
return $buffer;
654654

655655
// Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit(). This doesn't work below PHP 4.3.0, because it makes the output buffer bigger.
656656
// @todo smflib
657-
if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot'))
658-
$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
657+
if (empty($_COOKIE) && session_id() != '' && !isBrowser('possibly_robot'))
658+
$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(session_id(), '/') . ')\\??/', '"' . $scripturl . '?' . session_id() . '&amp;', $buffer);
659659
// Debugging templates, are we?
660660
elseif (isset($_GET['debug']))
661661
$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer);
@@ -664,14 +664,14 @@ function ob_sessrewrite($buffer)
664664
if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd'] || $context['server']['is_litespeed']))
665665
{
666666
// Let's do something special for session ids!
667-
if (defined('SID') && SID != '')
667+
if (session_id() != '')
668668
$buffer = preg_replace_callback(
669-
'~"' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~',
669+
'~"' . preg_quote($scripturl, '~') . '\?(?:' . session_id() . '(?:;|&|&amp;))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~',
670670
function($m)
671671
{
672672
global $scripturl;
673673

674-
return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . '"';
674+
return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . session_id() . (isset($m[2]) ? $m[2] : "") . '"';
675675
},
676676
$buffer
677677
);

Sources/Subs.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,20 +4062,20 @@ function redirectexit($setLocation = '', $refresh = false, $permanent = false)
40624062
$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
40634063

40644064
// Put the session ID in.
4065-
if (defined('SID') && SID != '')
4066-
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
4065+
if (session_id() != '')
4066+
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(session_id(), '/') . ')\\??/', $scripturl . '?' . session_id() . ';', $setLocation);
40674067
// Keep that debug in their for template debugging!
40684068
elseif (isset($_GET['debug']))
40694069
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
40704070

40714071
if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
40724072
{
4073-
if (defined('SID') && SID != '')
4073+
if (session_id() != '')
40744074
$setLocation = preg_replace_callback(
4075-
'~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
4075+
'~^' . preg_quote($scripturl, '~') . '\?(?:' . session_id() . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
40764076
function($m) use ($scripturl)
40774077
{
4078-
return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
4078+
return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . session_id() . (isset($m[2]) ? "$m[2]" : "");
40794079
},
40804080
$setLocation
40814081
);

0 commit comments

Comments
 (0)