Opcode (APC/XCache), Zend, Doctrine, and Autoloaders

删除回忆录丶 提交于 2019-11-29 02:20:34

You could put a "Zend_Session::writeClose(true);" at the end of your index.php.
This will write the session into a persistent state before necessary Objects (Zend_Loader etc.) get destructed.

Better: Register it as shutdown function.
So it will be executed even if you use exit(), die() or a fatal error occures:

register_shutdown_function(array('Zend_Session', 'writeClose'), true);

It is probably similar to the problem with custom session handling and APC-cache. If you have assigned a custom session handler it is registered with RSHUTDOWN in PHP. It is the same routine that APC uses and will therefor create an internal conflict in PHP and your custom session handler will not close in all situations.

So you will have to make sure you manually close the custom session handler at shutdown

Putting a "Zend_Session::writeClose(true);" at the end of your index.php is not the best way to do that in case you have any exit; calls in your scripts anywhere.

It is better to register a shutdown handler in this way:

function shutdown()
{
 Zend_Session::writeClose(true);
}

register_shutdown_function('shutdown');

Put that in top of your index.php file to make sure that the shutdown procedure is registered before any other scripts are run.

Is there something else mucking the include path? Maybe try to log out the include path right before that line in your first APC example.

The XCache one is really weird. That project is pretty dead though, and I'd not trust it on PHP 5.2+. Try eaccelerator instead? We've had the best luck with it.

Benjamin Cremer, you're a life saver. While the above (original) problem is a special case of autoloading with sessions, closing the session seems to be a general solution for such cases. A note though:

Placing Zend_Session::writeClose(true); at the end of your scripts may not always cut it, since you may have exit;'s, die();'s, etc in your code. In this case, you can use

register_shutdown_function(array('Zend_Session', 'writeClose'), true);

or, simply

register_shutdown_function('session_write_close');

if you do not use Zend for sessions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!