diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-12-30 11:27:13 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-12-30 11:27:13 +0100 |
| commit | ed3811e7819333cb097cb510cb8833527834c9a9 (patch) | |
| tree | 93d6a29eae4640164697237134d359566a2eba7d | |
| parent | 935a61d03455abde63ef93b49a7e42541e71bfc0 (diff) | |
| download | php-git-ed3811e7819333cb097cb510cb8833527834c9a9.tar.gz | |
Revert "Increase serialize_lock while decoding session"
This reverts commit b8ef7c35abd31666d9fb317db4b09a9eef0ede6c.
See bug #79031. The semantics of serialize locking aren't quite
correct right now, and the use of the lock in this particular
place makes us hit the issue in a common case. I'm reverting this
commit for PHP 7.4 and will try to fix this properly for PHP 8,
as I believe it will require ABI breakage.
| -rw-r--r-- | ext/session/session.c | 9 | ||||
| -rw-r--r-- | ext/standard/tests/serialize/bug70219_1.phpt | 11 |
2 files changed, 7 insertions, 13 deletions
diff --git a/ext/session/session.c b/ext/session/session.c index 01c2d4b85a..671968e8da 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -244,18 +244,11 @@ static zend_string *php_session_encode(void) /* {{{ */ static int php_session_decode(zend_string *data) /* {{{ */ { - int res; if (!PS(serializer)) { php_error_docref(NULL, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object"); return FAILURE; } - /* Make sure that any uses of unserialize() during session decoding do not share - * state with any unserialize() that is already in progress (e.g. because we are - * currently inside Serializable::unserialize(). */ - BG(serialize_lock)++; - res = PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data)); - BG(serialize_lock)--; - if (res == FAILURE) { + if (PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data)) == FAILURE) { php_session_destroy(); php_session_track_init(); php_error_docref(NULL, E_WARNING, "Failed to decode session object. Session has been destroyed"); diff --git a/ext/standard/tests/serialize/bug70219_1.phpt b/ext/standard/tests/serialize/bug70219_1.phpt index 6492a9a21e..6bbc593b34 100644 --- a/ext/standard/tests/serialize/bug70219_1.phpt +++ b/ext/standard/tests/serialize/bug70219_1.phpt @@ -18,7 +18,6 @@ class obj implements Serializable { } function unserialize($data) { session_decode($data); - return null; } } @@ -34,18 +33,20 @@ for ($i = 0; $i < 5; $i++) { var_dump($data); var_dump($_SESSION); ?> ---EXPECT-- +--EXPECTF-- array(2) { [0]=> - object(obj)#1 (1) { + object(obj)#%d (1) { ["data"]=> NULL } [1]=> - object(obj)#2 (1) { + object(obj)#%d (1) { ["data"]=> NULL } } -array(0) { +object(obj)#1 (1) { + ["data"]=> + NULL } |
