|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-12-01 19:36 UTC] andrei@php.net
[2009-12-01 19:37 UTC] andrei@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 22:00:02 2025 UTC |
Description: ------------ The JSON serializer, as configured with $memcached->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_JSON); returns objects upon deserialization (i.e. $memcached- >get(...)) even if an array was added in the first place. It seems as though internally, json_decode($s) is being used instead of json_decode($s, true). (Perhaps there needs to be an Memcached::SERIALIZER_JSON and Memcached::SERIALIZER_JSON_OBJECT serialization styles.) Reproduce code: --------------- $memcached = new Memcached(); $memcached->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_JSON); $memcached->addServers(array(array("localhost", 11211))); $a1 = array("bar" => 3); print_r($a1); $memcached->set("foo", $a1); $a2 = $memcached->get("foo"); print_r($a2); Expected result: ---------------- Array ( [bar] => 3 ) Array ( [bar] => 3 ) Actual result: -------------- Array ( [bar] => 3 ) stdClass Object ( [bar] => 3 )