From 5fad4006e102ddec8afe17a1315971fed3d29376 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 01:15:50 +0100 Subject: [PATCH 1/5] [ticket/11212] Do not rely on $request in send_status_line() PHPBB3-11212 --- phpBB/includes/functions.php | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3a5b100515..dd82c9dc46 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2858,8 +2858,6 @@ function meta_refresh($time, $url, $disable_cd_check = false) */ function send_status_line($code, $message) { - global $request; - if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi') { // in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though @@ -2867,18 +2865,35 @@ function send_status_line($code, $message) } else { - if ($request->server('SERVER_PROTOCOL')) - { - $version = $request->server('SERVER_PROTOCOL'); - } - else - { - $version = 'HTTP/1.0'; - } + $version = get_http_version(); header("$version $code $message", true, $code); } } +/** +* Returns the HTTP version used in the current request. +* +* Handles the case of being called before `$request` is present, +* In which case it falls back to the $_SERVER superglobal. +* +* @return string HTTP version +*/ +function get_http_version() +{ + global $request; + + if ($request && $request->server('SERVER_PROTOCOL')) + { + return $request->server('SERVER_PROTOCOL'); + } + else if (isset($_SERVER['SERVER_PROTOCOL'])) + { + return $_SERVER['SERVER_PROTOCOL']; + } + + return 'HTTP/1.0'; +} + //Form validation From 9cdef7984f5162fa19ce36852331f79de3561f66 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 01:17:23 +0100 Subject: [PATCH 2/5] [ticket/11212] Allow dispatcher to be absent during garbage_collection() PHPBB3-11212 --- phpBB/includes/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index dd82c9dc46..4754d5194f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5348,7 +5348,9 @@ function garbage_collection() * @event core.garbage_collection * @since 3.1-A1 */ - $phpbb_dispatcher->dispatch('core.garbage_collection'); + if (!empty($phpbb_dispatcher)) { + $phpbb_dispatcher->dispatch('core.garbage_collection'); + } // Unload cache, must be done before the DB connection if closed if (!empty($cache)) From b534a7a5790df55ab5f0d8aba8f40080d481bac4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 01:25:14 +0100 Subject: [PATCH 3/5] [ticket/11212] Rename get_http_version to phpbb_request_http_version() PHPBB3-11212 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4754d5194f..495f83e3a6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2865,7 +2865,7 @@ function send_status_line($code, $message) } else { - $version = get_http_version(); + $version = phpbb_request_http_version(); header("$version $code $message", true, $code); } } @@ -2878,7 +2878,7 @@ function send_status_line($code, $message) * * @return string HTTP version */ -function get_http_version() +function phpbb_request_http_version() { global $request; From 1affc35be9a5ee2cdf2cd2551e708c928fb96d88 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 01:25:38 +0100 Subject: [PATCH 4/5] [ticket/11212] Cosmetics PHPBB3-11212 --- phpBB/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 495f83e3a6..dbc040e5fe 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2873,7 +2873,7 @@ function send_status_line($code, $message) /** * Returns the HTTP version used in the current request. * -* Handles the case of being called before `$request` is present, +* Handles the case of being called before $request is present, * In which case it falls back to the $_SERVER superglobal. * * @return string HTTP version @@ -5348,7 +5348,8 @@ function garbage_collection() * @event core.garbage_collection * @since 3.1-A1 */ - if (!empty($phpbb_dispatcher)) { + if (!empty($phpbb_dispatcher)) + { $phpbb_dispatcher->dispatch('core.garbage_collection'); } From b8cf74217aacb90ac066eee4e8812a2c32caa58a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 17 Nov 2012 01:32:40 +0100 Subject: [PATCH 5/5] [ticket/11212] Cosmetic surgery done right PHPBB3-11212 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index dbc040e5fe..ab4c7e1772 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2874,7 +2874,7 @@ function send_status_line($code, $message) * Returns the HTTP version used in the current request. * * Handles the case of being called before $request is present, -* In which case it falls back to the $_SERVER superglobal. +* in which case it falls back to the $_SERVER superglobal. * * @return string HTTP version */