php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60657 APC destroys static class members before sessions are written
Submitted: 2012-01-04 17:25 UTC Modified: 2013-06-27 20:14 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 5 (80.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: astewart at online-buddies dot com Assigned:
Status: Wont fix Package: Session related
PHP Version: 5.3.8 OS: MacOS X 10.7, CentOS 5.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: astewart at online-buddies dot com
New email:
PHP Version: OS:

 

 [2012-01-04 17:25 UTC] astewart at online-buddies dot com
Description:
------------
Like #59564.

Neither of the workarounds in that work for us: session is compiled in 
statically, but APC is a module, so we can't reorder them relative to each other, 
and an append doesn't work, and doesn't work with scripts that call exit()


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-02 11:47 UTC] gedrox at gmail dot com
This is actual in 5.3.10 as well. Simple code to reproduce (will log fatal 
errors about undefined class constant 'logging'):

<?php

$session = new XSession();

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

class XSession {
const logging = false;
function open() {if (self::logging) echo 'OK';}
function write() {if (self::logging) echo 'OK';}
function read() {if (self::logging) echo 'OK';}
function close() {if (self::logging) echo 'OK';}
function destroy() {if (self::logging) echo 'OK';}
function gc() {if (self::logging) echo 'OK';}
}
 [2013-06-27 20:14 UTC] arpad@php.net
-Status: Open +Status: Wont fix
 [2013-06-27 20:14 UTC] arpad@php.net
You should be able to work around this with register_shutdown_function('session_write_close'), or if using a class like in gedrox's example and PHP >= 5.4 you can make it implement SessionHandlerInterface and just call session_set_save_handler($session) which should also take care of this.

I'm afraid it's a chicken and egg problem and if the above workarounds don't work either then I don't see a practical solution.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 01 02:01:29 2025 UTC