Currently object's destructors are called in the zend_deactivate function in
main.c after the modules
request_shutdown_func has been called (main.c -
php_call_shutdown_functions(void); ) .
Since no code should be executed after module request shutdown unexpected
behaviour might
occur like the one descibed in bug#27555 affecting the session extension.
Maybe somebody can take a look.
./regards
Florian
<?php
// Short test which saves a session in the destructor
class TestSession {
public static $oSessionMap;
public function __construct() {
session_start()
;
if( empty($_SESSION['sessionObject']) ) {
TestSession::$oSessionMap = array();
} else if ( ! is_array(TestSession::$oSessionMap) ) {
TestSession::$oSessionMap = unserialize( $_SESSION['sessionObject'] );
} // if / else
} // public function __construct
public function add( $sKey, $sValue ) {
TestSession::$oSessionMap[ $sKey ] = $sValue;
} // public function add
public function get( $sKey ) {
return TestSession::$oSessionMap[ $sKey ];
} // public function get
public function __destruct() {
$_SESSION['sessionObject'] = serialize(TestSession::$oSessionMap);
} // public function __destruct
} // class Session
$oSes = new TestSession();
echo $oSes->get("test1","testval");
$oSes->add("test1","testval");
?
Hello Florian, hello Andi
to me this is the way to go. At least the order of shutdown pieces
is correct with this patch but maybe Andi has a better idea?
regards
marcus
Friday, July 2, 2004, 11:51:44 PM, you wrote:
Currently object's destructors are called in the zend_deactivate function in
main.c after the modules
request_shutdown_func has been called (main.c -
php_call_shutdown_functions(void); ) .
Since no code should be executed after module request shutdown unexpected
behaviour might
occur like the one descibed in bug#27555 affecting the session extension.