From 9c57e5f5f5cf1b06717c420782931bfd04e22d58 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 16 Sep 2013 18:10:47 -0700 Subject: [PATCH] Protect against non-arrays when fetching headers PHP documentation says this can theoretically return false on failure. HHVM actually returns null when running from the command line, so this does protect against that. Change-Id: I0d75b8ed209128a9667ce1e7189597ae9ebc8af6 --- includes/WebRequest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 55bddfc8f3..23eee04044 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -881,8 +881,9 @@ class WebRequest { return; } - if ( function_exists( 'apache_request_headers' ) ) { - foreach ( apache_request_headers() as $tempName => $tempValue ) { + $apacheHeaders = function_exists( 'apache_request_headers' ) ? apache_request_headers() : false; + if ( $apacheHeaders ) { + foreach ( $apacheHeaders as $tempName => $tempValue ) { $this->headers[strtoupper( $tempName )] = $tempValue; } } else { -- 2.20.1