From: alan at klestoff dot ru Operating system: Debian PHP version: 5.3.22 Package: Scripting Engine problem Bug Type: Bug Bug description:Unserialize array of objects whose class can't be autoloaded fail
Description: ------------ We have serialized object of class A and array with 2 such objects <?php class A {} echo serialize(new A()).PHP_EOL; echo serialize(array(new A(), new A())).PHP_EOL; ?> Then we write autoload function which throws exception if can't find a file with class. And in first case - we have a normal behaviour (we can catch exception). In second we have uncaughted exception. Test script: --------------- <?php spl_autoload_register( function($class) { if (!file_exists($class.'.php')) throw new Exception(); require_once $class.'.php'; } ); try { var_dump(unserialize('O:1:"A":0:{}')); echo 'Serialized'.PHP_EOL; } catch (Exception $e) { echo 'Failed'.PHP_EOL; } try { var_dump(unserialize('a:2:{i:0;O:1:"A":0:{}i:1;O:1:"A":0:{}}')); echo 'Serialized'.PHP_EOL; } catch (Exception $e) { echo 'Failed'.PHP_EOL; } Expected result: ---------------- Failed Failed Actual result: -------------- Failed PHP Fatal error: Uncaught exception 'Exception' in -:5 Stack trace: #0 [internal function]: {closure}('A') #1 [internal function]: spl_autoload_call('A') #2 -(20): unserialize('a:2:{i:0;O:1:"A...') #3 {main} Next exception 'Exception' in -:5 Stack trace: #0 [internal function]: {closure}('A') #1 -(0): spl_autoload_call('A') #2 {main} thrown in - on line 5 -- Edit bug report at https://bugs.php.net/bug.php?id=64354&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64354&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64354&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64354&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64354&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64354&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64354&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64354&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64354&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64354&r=support Expected behavior: https://bugs.php.net/fix.php?id=64354&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64354&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64354&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64354&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64354&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64354&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64354&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64354&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64354&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64354&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64354&r=mysqlcfg