diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-17 12:24:15 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-17 12:24:15 -0500 |
commit | e07db8fb8cd75acfb889e1c69874157a2782d1f6 (patch) | |
tree | 7ed61b85b716423dcba078b207b465890f122c86 | |
parent | 65dde648cab316fd0f0715f13d57ef45452398a3 (diff) | |
parent | b8cf74217aacb90ac066eee4e8812a2c32caa58a (diff) | |
download | forums-e07db8fb8cd75acfb889e1c69874157a2782d1f6.tar forums-e07db8fb8cd75acfb889e1c69874157a2782d1f6.tar.gz forums-e07db8fb8cd75acfb889e1c69874157a2782d1f6.tar.bz2 forums-e07db8fb8cd75acfb889e1c69874157a2782d1f6.tar.xz forums-e07db8fb8cd75acfb889e1c69874157a2782d1f6.zip |
Merge PR #1097 branch 'igorw/ticket/11212' into develop
* igorw/ticket/11212:
[ticket/11212] Cosmetic surgery done right
[ticket/11212] Cosmetics
[ticket/11212] Rename get_http_version to phpbb_request_http_version()
[ticket/11212] Allow dispatcher to be absent during garbage_collection()
[ticket/11212] Do not rely on $request in send_status_line()
-rw-r--r-- | phpBB/includes/functions.php | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3a5b100515..ab4c7e1772 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 = phpbb_request_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 phpbb_request_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 @@ -5333,7 +5348,10 @@ 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)) |