Add __destruct to SessionManager #3429

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@mwillbanks
Contributor

Overview

Adds a __destruct method into the SessionManager to ensure that writeClose is called prior to PHP destroying the object references from a session becoming closed. When the destructor is called it will then call writeClose; in the event that writeClose was already called the storage would then be marked as Immutable. Therefore writeClose now additionally checks to ensure that if the storage is immutable it will not execute the closing again.

This issue happens primarily when utilizing a database storage handler or something that rewrite other resources.

Issues Resolved

#2628
#3075
#3108
#3182

@mwillbanks mwillbanks Resolves: #2628 adds a destructor into SessionManager to call writeCl…
…ose, writeClose now checks to see if the storage is immutable prior to attempting to save since the destructor may call writeClose a second time
ece67a2
@weierophinney weierophinney added a commit that referenced this pull request Jan 14, 2013
@weierophinney weierophinney Merge branch 'hotfix/3429' into develop
Forward port #3429
11508cc
@weierophinney weierophinney added a commit that closed this pull request Jan 14, 2013
@weierophinney weierophinney Merge branch 'hotfix/3429'
Close #3429
Fixes #2628
Fixes #3075
Fixes #3108
Fixes #3182
da2fb69
@kuising

There seems to be more bugs related to SessionManager->writeClose(). Even with the version of SessionManager.php in ZF2 v2.2, which calls
register_shutdown_function(array($this, 'writeClose'));
in the constructor, and has your changes in its writeClose() function, I continue to see these errors when trying Session with DbTable storage. As you can see from the call stacks, writeClose() is called. Things start to go bad after this call. Any comment on this please?

This appears before logging in:

Fatal error: Class 'Zend\Db\Sql\Insert' not found in B:\wamp\www\Album\vendor\ZF2\library\Zend\Db\Sql\Sql.php on line 88

Call Stack

Time

Memory

Function

Location

1 0.1622 10126880 Zend\Session\SessionManager->writeClose( ) ..\SessionManager.php:0
2 0.1622 10127040 session_write_close ( ) ..\SessionManager.php:166
3 0.1622 10127456 Zend\Session\SaveHandler\DbTableGateway->write( ) ..\SessionManager.php:166
4 0.1630 10133968 Zend\Db\TableGateway\AbstractTableGateway->insert( ) ..\DbTableGateway.php:141
5 0.1630 10134080 Zend\Db\Sql\Sql->insert( ) ..\AbstractTableGateway.php:256

This appears after logging in:

Fatal error: Class 'Zend\Db\Sql\Update' not found in B:\wamp\www\Album\vendor\ZF2\library\Zend\Db\Sql\Sql.php on line 100

Call Stack

Time

Memory

Function

Location

1 0.1505 9166192 Zend\Session\SessionManager->writeClose( ) ..\SessionManager.php:0
2 0.1506 9166352 session_write_close ( ) ..\SessionManager.php:166
3 0.1506 9169176 Zend\Session\SaveHandler\DbTableGateway->write( ) ..\SessionManager.php:166
4 0.1515 9179312 Zend\Db\TableGateway\AbstractTableGateway->update( ) ..\DbTableGateway.php:135
5 0.1515 9179448 Zend\Db\Sql\Sql->update( ) ..\AbstractTableGateway.php:313

@weierophinney weierophinney added a commit to zendframework/zend-session that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/3429' into develop 40f3c34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment