Bug #79382 [Com]: Fatal error: Cannot redeclare getallheaders() in ...
| From: | bugreports at gmail dot com | Date: | Sat, 14 Mar 2020 14:22:39 +0000 |
| Subject: | Bug #79382 [Com]: Fatal error: Cannot redeclare getallheaders() in ... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226109@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79382&edit=1
ID: 79382
Comment by: bugreports at gmail dot com
Reported by: admin at franceserv dot fr
Summary: Fatal error: Cannot redeclare getallheaders() in ...
Status: Open
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 7.3.15 and 7.4
Block user comment: N
Private report: N
New Comment:
"disable_functions" should throw an exception when a disabled function is called so one
can handle it proper without spread *slow and expensive* function exists into the codebase -
try/catch is much faster in cases where it don't throw
such compat layers defining a function which is part of a newer php release should go into a include
file because code like below would be completly optimized out by opcache given the constant nature
known at "compile time"
if(PHP_VERSION_ID < 70300)
{
require 'php73.inc.php';
}
Previous Comments:
------------------------------------------------------------------------
[2020-03-14 14:14:34] admin at franceserv dot fr
This strange behavior seem to exist since 13 years at least :
https://www.php.net/manual/fr/function.function-exists.php#67947
When a function is disabled, if we check this function with function_exists() it's reply
"don't exist", but if we are trying to declare the function it's reply
"exist already". Funny :)
------------------------------------------------------------------------
[2020-03-14 13:20:45] admin at franceserv dot fr
My friend and me found the BUG :)
When the function "getallheaders" is disabled with disable_functions in php.ini, the
function isn't visible by function_exists() but if we redeclare it, it's raise an error
(instead a disabled function warning).
We are thinking it's really a bug because before 7.3 the behavior isn't same.
Could you check on your side please with PHP 7.3.x or 7.4.x ?
------------------------------------------------------------------------
[2020-03-14 12:36:43] admin at franceserv dot fr
Yes exactly, the file is this one :
https://github.com/ralouphie/getallheaders/blob/develop/src/getallheaders.php
The condition "if (!function_exists('getallheaders'))" isn't checked and I
need (same for few people over Internet too) rename the function "function
getallheaders()" to "function _something_different_here_getallheaders()" to avoid the
problem ...
A friend is using PHP 7.4 and he don't have this problem, but I don't know where to look
because a configuration which change behavior of the function "function_exists()" is very
strange.
------------------------------------------------------------------------
[2020-03-14 10:31:56] cmb@php.net
Among others, this is about <https://github.com/ralouphie/getallheaders/blob/develop/src/getallheaders.php>.
------------------------------------------------------------------------
[2020-03-14 08:48:50] nikic@php.net
I doubt this is opcache related. PHP 7.3 added getallheaders() for the FPM SAPI and the code also
tries to define this function. You mention that there is a function_exists check, which should have
prevented this. Can you share what the file that containts the getallheaders() declaration looks
like?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=79382
--
Edit this bug report at https://bugs.php.net/bug.php?id=79382&edit=1