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

From: Date: Wed, 17 Jun 2015 11:55:51 +0000
Subject: Bug #69861 [NEW]: Callable fields are treated as magic __call()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193602@lists.php.net to get a copy of this message
From: php at developerjack dot com Operating system: All PHP version: 7.0.0alpha1 Package: Scripting Engine problem Bug Type: Bug Bug description:Callable fields are treated as magic __call() 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 bug report at https://bugs.php.net/bug.php?id=69861&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69861&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69861&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69861&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69861&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69861&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69861&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69861&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69861&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69861&r=support Expected behavior: https://bugs.php.net/fix.php?id=69861&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69861&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69861&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69861&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69861&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69861&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69861&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69861&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69861&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69861&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69861&r=mysqlcfg

« previous php.bugs (#193602) next »