Bug #52937 [Com]: call_user_func warning is inappropriate
| From: | georgir at gmail dot com | Date: | Mon, 23 Mar 2015 10:05:01 +0000 |
| Subject: | Bug #52937 [Com]: call_user_func warning is inappropriate | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191544@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=52937&edit=1
ID: 52937
Comment by: georgir at gmail dot com
Reported by: mryaggi at hotmail dot com
Summary: call_user_func warning is inappropriate
Status: Wont fix
Type: Bug
Package: Scripting Engine problem
Operating System: Seven
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
> What's the issue you're seeing with call_user_func_array?
The issue is that a) the check for a reference does not catch the case when a literal value is
provided (seems fixed in php7); b) the function is not executed at all, instead of the more graceful
fallback of executing it without changing the value that was not a reference (while still issuing
the warning).
http://3v4l.org/WRkIH
Thank you for pointing out the change in 5.4, nikic, I was not aware of it. With it, a decent
workaround is possible:
http://3v4l.org/rJ2TZ
So this means that we have good workarounds for all cases now. And those that want can even
"fix" PHP with some runkit magic in a prepend script to replace those functions with the
workarounds.
Now the only thing left that I do not understand is why they would not be fixed in the PHP core
directly. But it is of less concern to me now that I'm aware of the workarounds.
Thank you for your time.
Previous Comments:
------------------------------------------------------------------------
[2015-03-23 07:51:19] nikic@php.net
@georgir: What's the issue you're seeing with call_user_func_args? Your statement
> If you use call_user_func_array('foo', array(&$b))
> when the function foo takes an argument by copy
> instead of by reference and modifies it thinking
> it doesn't matter, $b will still be modified,
> which is most certainly undesired.
is not true for any supported versions of PHP, as you can easily verify: http://3v4l.org/dWMfe
------------------------------------------------------------------------
[2015-03-23 02:52:48] georgir at gmail dot com
cmbecker69, you are right, so we have an ok workaround for call_user_func.
it is still strange why two things that should be equivalent can not be implemented equivalently,
however.
and it still leaves the more used call_user_func_array bugged with no workaround.
------------------------------------------------------------------------
[2015-03-22 22:30:30] cmbecker69 at gmx dot de
> $func() isn't always an option as it is not usable with method
> calls, etc.
To my knowledge, variable functions work for all callables (i.e.
is_callable($func) !== true) since PHP 5.4. Older versions have
already reached their EOL.
------------------------------------------------------------------------
[2015-03-22 17:15:24] georgir at gmail dot com
wow, that wontfix...
as said above, call_user_func_array is affected by the same bug.
and even for call_user_func, $func() isn't always an option as it is not usable with method
calls, etc.
------------------------------------------------------------------------
[2015-03-21 20:23:02] nikic@php.net
Closing as Won't Fix, because
a) since PHP 5.4 you can just use $callback($arg1, $arg2, ...) instead (which supports references)
b) you can use call_user_func_array() if you really want to stick with it.
------------------------------------------------------------------------
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=52937
--
Edit this bug report at https://bugs.php.net/bug.php?id=52937&edit=1