php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62596 getallheaders() missing with PHP-FPM
Submitted: 2012-07-18 12:09 UTC Modified: 2017-10-24 07:08 UTC
Votes:90
Avg. Score:4.4 ± 0.9
Reproduced:85 of 86 (98.8%)
Same Version:31 (36.5%)
Same OS:59 (69.4%)
From: phofstetter at sensational dot ch Assigned:
Status: Closed Package: FPM related
PHP Version: 5.4.4 OS: MacOS X, Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phofstetter at sensational dot ch
New email:
PHP Version: OS:

 

 [2012-07-18 12:09 UTC] phofstetter at sensational dot ch
Description:
------------
getallheaders() is supposed to be available outside of the Apache SAPI since PHP 
5.4.0.

This is true for php-cgi for example, but it is not true for php-fpm where 
getallheaders() still causes

 Fatal error: Call to undefined function getallheaders()

Test script:
---------------
<?php

var_dump(getallheaders());

Expected result:
----------------
I expect to see the query headers (I need getallheaders() to get the OAuth bearer 
token from the Authorization header which unfortunately doesn't survive the move 
into $_SERVER)

Actual result:
--------------
 Fatal error: Call to undefined function getallheaders()

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-16 12:54 UTC] nospam dot a5ef at gribouille dot eu
I'm having the same issue. 
getallheaders() works fine using PHP-CGI (5.5.3), but compiling and using a 5.5.3 
PHP-FPM will raise a Fatal error: Call to undefined function getallheaders()

A fix would be much appreciated.
 [2014-03-04 03:47 UTC] yinchuan dot blue at gmail dot com
PHP 5.4.9 with php-fpm having this issuse.
A fix would be much appreciated.
 [2014-04-29 12:39 UTC] simon at ikanobori dot jp
Running PHP-FPM, 5.4.4 this is present.

The documentation on http://www.php.net/manual/en/function.getallheaders.php mentions that this function became available from 5.4.0 for FastCGI and my PHP-FPM tells me its API is FPM/FastCGI.

A solution is to either update the documentation with the workarounds mentioned in the comments or to more clearly define that this is not available for PHP-FPM.

Or adding it to PHP-FPM.
 [2014-06-21 19:54 UTC] zaunere at gmail dot com
The documentation is misleading and regardless this type of functionality should be transparent across all SAPIs (where applicable) - especially one as relevant as FPM.

Thank you!
 [2014-11-13 21:41 UTC] fmargaine@php.net
-Assigned To: +Assigned To: fmargaine
 [2015-07-21 21:25 UTC] php at vossey dot net
This ommission is now 4 years old...

I know the PHP team hate distribution patches, but Debian has integrated a patch that fix this missing function for FPM, at least for 5.6 (0046-getallheaders-for-php-fpm-62596.patch).

Why not take it?
 [2015-07-21 21:46 UTC] darck at vossey dot net
*3 years old

I hope it's not going to be 4 :)
 [2015-07-21 21:54 UTC] yohgaki@php.net
I suggested generic name for the function when the change was made. e.g. sapi_header_get_all(), sapi_header_send(), etc.

It would be time to cleanup all function naming mess.
https://wiki.php.net/rfc/consistent_function_names
 [2015-07-21 22:29 UTC] cmb@php.net
There's PR #910[1] lying around since quite a while – not sure why it hasn't been merged yet.

[1] <https://github.com/php/php-src/pull/910> (It doesn't seem possible to add this to the PR section, BTW)
 [2016-06-12 21:45 UTC] anrdaemon at freemail dot ru
4 years?
 [2016-06-16 16:44 UTC] alex at tresorg dot com
I hope its not going to be 5 years
 [2016-10-25 22:31 UTC] fredrik at neam dot se
It seems that https://github.com/php/php-src/pull/910 is not even accepted for 7.1 even. 

In the meantime, @ralouphie has a polyfill that can be installed via composer: https://github.com/ralouphie/getallheaders making the function available in all scripts that loads the composer autoloader.

PS I tried adding https://github.com/php/php-src/pull/910 to this bug report but I could only choose PRs with ids from around 1800+
 [2016-10-27 21:42 UTC] yohgaki@php.net
Let's clean up function name mess now and add it (them).
Need RFC for this. If nobody cares, I may handle this. Assign this bug to me.
 [2017-07-28 09:59 UTC] jso at json dot com
so much years . why not fix this bug?
 [2017-10-24 07:08 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: fmargaine +Assigned To:
 [2017-10-24 08:20 UTC] nospam dot ty5l at gribouille dot eu
Hello, I also commented here in 2013 for this bug to be fixed. 
Apparently a person has been assigned to this bug in 2014. 
Today 2017, it has been "un"assigned. 

Does this means this bug will never get fixed ?
 [2017-12-14 11:01 UTC] chris dot collins at boxuk dot com
It would be good if this could be resolved. It appears it has got close to being fixed in 5.5 and 5.6, but both times PRs have been closed due to those versions lapsing into "security fix only" mode. It's still present in PHP 7.

The previously mentioned workaround to use a polyfill (ralouphie/getallheaders) works: at the very least http://php.net/manual/en/function.getallheaders.php should be updated to indicate this method is not always available.
 [2018-01-08 22:51 UTC] hobbsogblin at gmail dot com
Popular Linux distributions will begin defaulting to PHP-FPM in the not-so-distant future. Fedora 27 has already done so. It may be wise to get ahead of this issue.
 [2018-07-05 04:31 UTC] remi@php.net
Automatic comment on behalf of remi@remirepo.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0ea4013f101d64fbeb9221260b36e98f10ed1ddd
Log: Fixed bug #62596 add getallheaders (apache_request_headers) missing function in FPM add sapi_add_request_header in public API (was add_request_header) fix arginfo for fastcgi_finish_request fucntion
 [2018-07-05 04:31 UTC] remi@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 04 06:01:28 2024 UTC