If getallheaders() is not available, implement it ourselves.

This commit is contained in:
Michael Stenta 2020-07-24 09:40:32 -04:00
parent 7424cb9a54
commit b8159138d9
1 changed files with 19 additions and 0 deletions

View File

@ -26,6 +26,25 @@ function farm_access_init() {
}
}
/**
* If getallheaders() is not available, implement it ourselves.
*
* This is necessary in PHP CLI and Nginx contexts.
* See https://github.com/farmOS/farmOS/issues/271#issuecomment-663543706
*
* Code is taken from http://php.net/manual/en/function.getallheaders.php
*/
if (!function_exists('getallheaders')) {
function getallheaders() {
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
/**
* Implements hook_hook_info().
*/