|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59386 APC change default behaviour when PHP shuts down with APC/FastCGI
Submitted: 2010-08-25 10:08 UTC Modified: 2016-11-18 21:51 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.2.13 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2010-08-25 10:08 UTC]
I do not have the same behaviour with or without APC enabled, when handling php shutdown, especially session_set_save_handler.
This only happen when using FastCGI of course :) Maybe it happens with PHP as a module, I did not test it.

First time the script is executed : no error. Second time (and third, ...) : error happened.

For helping you reproduce the bug, here are the command lines used with cgi-fcgi : 

$ cgi-fcgi -start -connect test.sock /usr/bin/php-cgi

Then, call the following command line several times :
$ SCRIPT_FILENAME=bugapc.php cgi-fcgi  -connect test.sock /usr/bin/php-cgi

Reproduce code:

class MyTest {
    public function __construct() { }
    public function open () { }
    public function close () { echo __FUNCTION__;}
    public function read () { }
    public function write () { echo __FUNCTION__;}
    public function destroy () { }
    public function gc () { }

    array('MyTest', 'open'),
    array('MyTest', 'close'),
    array('MyTest', 'read'),
    array('MyTest', 'write'),
    array('MyTest', 'destroy'),
    array('MyTest', 'gc')

Expected result:
First launch (no error) : 

Actual result:
First launch is expected result.

Then : 
Fatal error: Class 'MyTest' not found in Unknown on line 0
Fatal error: Class 'MyTest' not found in Unknown on line 0

=> Error happened when php called MyTest::write() and MyTest::close() internally.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-25 10:12 UTC]
This is a bit of a chicken+egg situation that probably should 
be fixed on the PHP side.  We just haven't quite figure out 
how yet.  For now, if you simply call session_write_close() 
yourself when you are done with the session, everything will 
work both with and without APC.
 [2010-08-25 10:17 UTC]
I cannot use __destruct() as my session handler is static.

Using session_write_close() force me to use something like auto_append_file or register_shutdown_function(), to make sure this is called after everything else, right ?
 [2010-08-25 10:21 UTC]
It doesn't have to be called after everything, just call it 
when you know you don't need anything from the session 
 [2016-11-18 21:51 UTC]
-Status: Analyzed +Status: Wont fix
 [2016-11-18 21:51 UTC]
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 00:01:33 2024 UTC