Bug #72171 [NEW]: unserialize() throws a Fatal Error on inaccessible parent classes

From: Date: Fri, 06 May 2016 11:48:16 +0000
Subject: Bug #72171 [NEW]: unserialize() throws a Fatal Error on inaccessible parent classes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200920@lists.php.net to get a copy of this message
From: php at maisqi dot com Operating system: Windows, Linux PHP version: 7.0.6 Package: Scripting Engine problem Bug Type: Bug Bug description:unserialize() throws a Fatal Error on inaccessible parent classes Description: ------------ When unserialize() finds a non-defined class it tries to autload it; but if that succeeds, but that class' base class is not "autoloadable", a Fatal Error is thrown. This makes the unserialize() function totally unpredictable, because we should get a couple of references to __PHP_Incomplete_Class but may just as well get the script aborted. Test script: --------------- <?php // file: "test.php" spl_autoload_register(function($className) {}); spl_autoload_register(function($className) { require_once 'ExistingClass.php'; }); $code = 'O:13:"ExistingClass":0:{}'; $o = unserialize($code); print_r($o); // file ends <?php // file: "ExistingClass.php" class ExistingClass extends NonExistingClass {} // file ends Expected result: ---------------- unserialize() should return a __PHP_Incomplete_Class object. Actual result: -------------- It throws a Fatal Error. This happens in PHP 7.0.6 x64 running on Windows 8 and in PHP 5.5.33 running on Linux CentOS. -- Edit bug report at https://bugs.php.net/bug.php?id=72171&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72171&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72171&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72171&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72171&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72171&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72171&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72171&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72171&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72171&r=support Expected behavior: https://bugs.php.net/fix.php?id=72171&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72171&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72171&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72171&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72171&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72171&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72171&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72171&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72171&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72171&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72171&r=mysqlcfg

« previous php.bugs (#200920) next »