From a6f088992b4d75df91df75f8d183a12f9fa12777 Mon Sep 17 00:00:00 2001
From: Andreas Fischer <bantu@phpbb.com>
Date: Tue, 7 Jul 2009 15:18:11 +0000
Subject: [PATCH] Fix bug #47785 - Fetch requested cookie variables directly
 from cookie super global. This should fix a problem with phpBB installations
 on PHP 5.3

Authorised by: naderman

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9728 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/docs/CHANGELOG.html    | 1 +
 phpBB/includes/functions.php | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index a2d730e6a6..ac8775b0a0 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -161,6 +161,7 @@
 		<li>[Change] &quot;Post details&quot; links with image in MCP. (Bug #39845 - Patch by leviatan21)</li>
 		<li>[Change] Pm history only shows pms of the receipts you currently reply to (Bug #39505 - Patch by nickvergessen)</li>
 		<li>[Change] Add quote-button for own pm's in pm-history (Bug #37285 - Patch by nickvergessen)</li>
+		<li>[Change] Fetch requested cookie variables directly from cookie super global. (Bug #47785)</li>
 		<li>[Feature] Add confirmation for deactivating styles (Bug #14304 - Patch by leviatan21)</li>
 		<li>[Feature] Add language selection on the registration terms page (Bug #15085 - Patch by leviatan21)</li>
 		<li>[Feature] Add confirmation for deactivating language packs (Patch by leviatan21)</li>
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 25bef4557a..29f4186a5d 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -71,12 +71,13 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
 		$_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name];
 	}
 
-	if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name])))
+	$super_global = ($cookie) ? '_COOKIE' : '_REQUEST';
+	if (!isset($$super_global[$var_name]) || is_array($$super_global[$var_name]) != is_array($default))
 	{
 		return (is_array($default)) ? array() : $default;
 	}
 
-	$var = $_REQUEST[$var_name];
+	$var = $$super_global[$var_name];
 	if (!is_array($default))
 	{
 		$type = gettype($default);