|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58773 JSON serializer returns objects if arrays added
Submitted: 2009-07-24 06:37 UTC Modified: 2009-12-01 19:37 UTC
From: mjs at beebo dot org Assigned:
Status: Closed Package: memcached (PECL)
PHP Version: Irrelevant OS: OS X
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mjs at beebo dot org
New email:
PHP Version: OS:


 [2009-07-24 06:37 UTC] mjs at beebo dot org
The JSON serializer, as configured with


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);


$memcached->set("foo", $a1);

$a2 = $memcached->get("foo");


Expected result:
    [bar] => 3
    [bar] => 3

Actual result:
    [bar] => 3
stdClass Object
    [bar] => 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-01 19:36 UTC]
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at

 [2009-12-01 19:37 UTC]
Fixed for the next release, actually.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 12 21:01:30 2024 UTC