Bug #69761 [NEW]: Serialization of anonymous classes should be prevented

From: Date: Fri, 05 Jun 2015 17:19:26 +0000
Subject: Bug #69761 [NEW]: Serialization of anonymous classes should be prevented
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193152@lists.php.net to get a copy of this message
From: mhujer at gmail dot com Operating system: Windows 8/Linux PHP version: master-Git-2015-06-05 (snap) Package: *General Issues Bug Type: Bug Bug description:Serialization of anonymous classes should be prevented Description: ------------ According to the Anonymous classes RFC (https://wiki.php.net/rfc/anonymous_classes), it should not be possible to serialize them ("Serialization is not supported, and will error just as anonymous functions do."). But it is possible to serialize them in latest snapshot (Windows) or in 3v4l.org http://3v4l.org/tIEp7 - but the unserialization fails. When I try to serialize Closure, exception with "Serialization of 'Closure' is not allowed" is thrown. Test script: --------------- <?php $instance = new class('foo') { public function __construct($i) { var_dump($i); } }; var_dump($instance); var_dump(serialize($instance)); var_dump(unserialize(serialize($instance))); $a = function ($a) {}; var_dump($a); var_dump(serialize($a)); var_dump(unserialize(serialize($a))); -- Edit bug report at https://bugs.php.net/bug.php?id=69761&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69761&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69761&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69761&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69761&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69761&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69761&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69761&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69761&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69761&r=support Expected behavior: https://bugs.php.net/fix.php?id=69761&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69761&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69761&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69761&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69761&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69761&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69761&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69761&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69761&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69761&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69761&r=mysqlcfg

« previous php.bugs (#193152) next »