Bug #69861 [Opn]: Callable fields are treated as magic __call()

From: Date: Wed, 17 Jun 2015 11:58:39 +0000
Subject: Bug #69861 [Opn]: Callable fields are treated as magic __call()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193603@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69861&edit=1 ID: 69861 User updated by: php at developerjack dot com Reported by: php at developerjack dot com Summary: Callable fields are treated as magic __call() Status: Open Type: Bug Package: Scripting Engine problem Operating System: All PHP Version: 7.0.0alpha1 Block user comment: N Private report: N New Comment: A copy of the bug report in 3v4l.org - I found this useful to debug and play with to reproduce. http://3v4l.org/gQHkU Previous Comments: ------------------------------------------------------------------------ [2015-06-17 11:55:50] php at developerjack dot com Description: ------------ If a class has a magic __call() method, fields which are closure are not invoked. The result being that the $args param to __call() exceeds memory limits due to nesting recursively (and, depending on recursion and memory limits does not report as a recursion limit reached). On preliminary review, this may be related to the callable types and Classname::method() syntax: https://github.com/php/php-src/commit/989a13608b5154672e6ab94f970e271f7d0ae502 Test script: --------------- <?php class CallableStub { protected $callback = null; public function setCallback(callable $callback) { $this->callback = $callback; } public function __call($name, $args) { if($this->callback == null || !is_callable($this->callback)) { throw new \LogicException("CallableStub requires a callback function to be callable."); } //$cb = $this->callback; // $cb(); use a locl variable instead and it works! return $this->callback($name, $args); } } $s = new CallableStub(); $s->setCallback( function ($x, $y) { var_dump(func_get_args()); }); $s->frankfurt('rabbit stew'); Expected result: ---------------- --- expected --- $this->callback($someArgs);// invoke the closure in $this->callback; Actual result: -------------- --- actual --- $this->callback($someargs);// invokes __call('callback', [$someargs]); Error: Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/cg4kJ on line 16 Process exited with code 255. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69861&edit=1

« previous php.bugs (#193603) next »