Skip to content

Commit

Permalink
Use session_write_close() in Phalcon\Session\Adapter::__destruct()
Browse files Browse the repository at this point in the history
(cherry picked from commit cfd1909)
  • Loading branch information
sjinks committed Dec 21, 2013
1 parent 41da044 commit 64a2f60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ext/session/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ PHP_METHOD(Phalcon_Session_Adapter, __construct){
PHALCON_MM_RESTORE();
}

PHP_METHOD(Phalcon_Session_Adapter, __destruct) {

zval *started;

PHALCON_MM_GROW();

PHALCON_OBS_VAR(started);
phalcon_read_property_this(&started, getThis(), SL("_started"), PH_NOISY TSRMLS_CC);
if (zend_is_true(started)) {
phalcon_session_write_close(TSRMLS_C);
phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);
}

PHALCON_MM_RESTORE();
}

/**
* Starts the session (if headers are already sent the session will not be started)
*
Expand Down
2 changes: 2 additions & 0 deletions ext/session/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern zend_class_entry *phalcon_session_adapter_ce;
PHALCON_INIT_CLASS(Phalcon_Session_Adapter);

PHP_METHOD(Phalcon_Session_Adapter, __construct);
PHP_METHOD(Phalcon_Session_Adapter, __destruct);
PHP_METHOD(Phalcon_Session_Adapter, start);
PHP_METHOD(Phalcon_Session_Adapter, setOptions);
PHP_METHOD(Phalcon_Session_Adapter, getOptions);
Expand Down Expand Up @@ -61,6 +62,7 @@ ZEND_END_ARG_INFO()

PHALCON_INIT_FUNCS(phalcon_session_adapter_method_entry){
PHP_ME(Phalcon_Session_Adapter, __construct, arginfo_phalcon_session_adapter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Phalcon_Session_Adapter, __destruct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR)
PHP_ME(Phalcon_Session_Adapter, start, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Session_Adapter, setOptions, arginfo_phalcon_session_adapter_setoptions, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Session_Adapter, getOptions, NULL, ZEND_ACC_PUBLIC)
Expand Down

0 comments on commit 64a2f60

Please sign in to comment.