Bug #68138 [NEW]: spl_autoload_register fails to load object from session after session_start()

From: Date: Thu, 02 Oct 2014 20:42:33 +0000
Subject: Bug #68138 [NEW]: spl_autoload_register fails to load object from session after session_start()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187804@lists.php.net to get a copy of this message
From: michal dot rudnicki at epsi dot pl Operating system: Windows/Linux PHP version: 5.5.17 Package: Session related Bug Type: Bug Bug description:spl_autoload_register fails to load object from session after session_start() Description: ------------ Hi All, Problem: When loading classes with __autoload, restoring objects from session works regardless whether session_start() was called before or after __autoload was declared. When loading classes with spl_autoload_register, restoring objects from session only works when session_start() called after registering loader, and returns __PHP_Incomplete_Class object when called before registering loader. PHP and OS versions: - 5.5.1 on Windows 2008 Server 64 bit - 5.5.9 on Ubuntu Linux 14.04 64 bit Preparation: Create file Foo.php with empty declaration of class Foo. Test script: --------------- <?php session_start(); spl_autoload_register(function ($className) { include "{$className}.php"; }); isset($_SESSION["foo"]) or $_SESSION["foo"] = new Foo(); var_dump($_SESSION); Expected result: ---------------- array(1) { ["foo"]=> object(Foo)#2 (0) { } } Actual result: -------------- array(1) { ["foo"]=> object(__PHP_Incomplete_Class)#1 (1) { ["__PHP_Incomplete_Class_Name"]=> string(3) "Foo" } } -- Edit bug report at https://bugs.php.net/bug.php?id=68138&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68138&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68138&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68138&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68138&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68138&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68138&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68138&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68138&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68138&r=support Expected behavior: https://bugs.php.net/fix.php?id=68138&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68138&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68138&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68138&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68138&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68138&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68138&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68138&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68138&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68138&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68138&r=mysqlcfg

« previous php.bugs (#187804) next »