You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the msgpack session serialize handler in latest release from pecl (0.5.6). I tested this with both file and redis save handlers.
Here is the php array that is serialized in the session :
array(1) { ["acl_user"]=> array(2) { ["id"]=> string(10) "NGwnGUqwsr" ["status"]=> int(2) } }
Here is the result I expect (without ws added for readability...) :
\x81 \xa8 acl_user \x82 \xa2 id \xaa NGwnGUqwsr \xa6 status \x02
Here is the result I get :
\x82 \xc0 \x01 \xa8 acl_user \x82 \xa2 id \xaa NGwnGUqwsr \xa6 status \x02
It looks like there is a null indexed value of 1 added before getting to the expected array (I am no expert in msgpack decoding, so I might be wrong...).
This null indexed value makes it impossible to share session with other tools (like Lua in Redis for example) because null (or nil) cannot be used as a key to index a value.
Is it possible to get rid of this null indexed value that seems useless ?
A five second scan and here is something dodgy already:
zend_hash_internal_pointer_reset_ex(htval, &valpos);
for (;; zend_hash_move_forward_ex(htval, &valpos))
The lib could probably be sped up with foreach a as v, k in C and the key check for non-existent removed altogether.
So, this comes down to the fact that http_session_vars is a reference.
Later when this array is packed we pack the reference appropriately .
Since you are just passing these values to redis, and you don't need the ref 'extension type' you could/should(?) just use ini_set('msgpack.php_only', 0);
I made the following test case to confirm this behavior. Flip msgpack.php_only to see the changes.
I think this is a WONTFIX @laruence opinions? Everyone feel free to reopen if you aren't satisfied with this answer. Since we are dealing with outside deserialization this seems like the proper usage
Activity
golgote commentedon May 20, 2015
I forgot to mention that I am running PHP 5.6.6.
Thanks.
joeyhub commentedon May 20, 2015
A five second scan and here is something dodgy already:
zend_hash_internal_pointer_reset_ex(htval, &valpos);
for (;; zend_hash_move_forward_ex(htval, &valpos))
The lib could probably be sped up with foreach a as v, k in C and the key check for non-existent removed altogether.
joeyhub commentedon May 20, 2015
It's specific to sessions and in php 5.4.
Sean-Der commentedon Jul 28, 2015
Hey @golgote @joeyhub
So, this comes down to the fact that http_session_vars is a reference.
Later when this array is packed we pack the reference appropriately .
Since you are just passing these values to redis, and you don't need the ref 'extension type' you could/should(?) just use
ini_set('msgpack.php_only', 0);I made the following test case to confirm this behavior. Flip msgpack.php_only to see the changes.
I think this is a WONTFIX @laruence opinions? Everyone feel free to reopen if you aren't satisfied with this answer. Since we are dealing with outside deserialization this seems like the proper usage