|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-10-13 16:41 UTC] nicolas dot lepage at yahoo dot fr
Description: ------------ When trying to instantiate a class that is not defined within the write function that has been registered as a custom session save handler, the following problems occur : _ functions that have been registered by spl_autoload_register are not called _ a fatal error is generated by spl_autoload() In the reproduce code, the normal behavior would be to generate a fatal error 'class not found'. This problem occurs only in the write function and not in the others. Additionnaly, when I replace the instantiation code by a call to spl_autoload_functions(), the apache server crashes. It could be related to bug #37111. Reproduce code: --------------- <?php function test_autoload($className) { } function open($save_path, $session_name) { return true; } function close() { return true; } function read($id) { return ''; } function write($id, $sess_data) { new NotLoadedClass(); return true; } function destroy($id) { return true; } function gc($maxlifetime) { return true; } spl_autoload_register('test_autoload'); session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); session_start(); ?> Expected result: ---------------- Fatal error: Class 'NotLoadedClass' not found in F:\xampp\htdocs\test\test.php on line 18 Actual result: -------------- Fatal error: spl_autoload() [<a href='function.spl-autoload'>function.spl-autoload</a>]: Class NotLoadedClass could not be loaded in F:\xampp\htdocs\test\test.php on line 18 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 13:00:01 2025 UTC |
I can confirm that the submitted code to reproduce this problem also 'works' on a server without PHP APC installed (used <?php var_dump(function_exists('apc_add')); ?> to check). PHP version 5.2.12. Are there any other extensions that could cause this behavior? Loaded extensions: date, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, session, iconv, pcntl, readline, Reflection, standard, shmop, SimpleXML, SPL, sockets, exif, tokenizer, xml, cgi- fcgi, bcmath, curl, dba, dbase, dom, gd, htscanner, imap, json, ldap, mbstring, mcrypt, mhash, mysql, mysqli, pdf, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, soap, wddx, xmlreader, xmlrpc, xmlwriter, xsl, zip, Zend OptimizerJust experienced this issue after upgrading to PHP 5.3.3, APC 3.1.4 on Debian GNU/Linux 4.0. When using the session handler from an instance of a class it would give a fatal error: Fatal error: Undefined class constant... After switching to use static session handler methods there was no longer a fatal error, but it caused a segfault which was traced back to spl_autoload_register(). Tried a bunch of stuff but was able to fix the issue by registering a shutdown function similar to this: register_shutdown_function('shutdown'); function shutdown() { session_write_close(); }