From: Chad Horohoe Date: Tue, 17 Sep 2013 01:10:47 +0000 (-0700) Subject: Protect against non-arrays when fetching headers X-Git-Tag: 1.31.0-rc.0~18750^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=9c57e5f5f5cf1b06717c420782931bfd04e22d58;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 {