php.net |  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
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: odoucet@php.net Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.2.13 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
38 - 23 = ?
Subscribe to this entry?

 
 [2010-08-25 10:08 UTC] odoucet@php.net
Description:
------------
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:
---------------
<?php

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 () { }
}

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


Expected result:
----------------
First launch (no error) : 
==========
writeclose
==========

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.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-25 10:12 UTC] rasmus@php.net
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] odoucet@php.net
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] rasmus@php.net
It doesn't have to be called after everything, just call it 
when you know you don't need anything from the session 
anymore.
 [2016-11-18 21:51 UTC] kalle@php.net
-Status: Analyzed +Status: Wont fix
 [2016-11-18 21:51 UTC] kalle@php.net
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: Thu Mar 28 08:01:28 2024 UTC