diff --git a/msgpack_pack.c b/msgpack_pack.c index 10934eb..0e11f4c 100644 --- a/msgpack_pack.c +++ b/msgpack_pack.c @@ -276,35 +276,28 @@ inline static void msgpack_serialize_array( if (object) { - if (n == 0) - { - msgpack_pack_map(buf, n); - } - else - { - if (MSGPACK_G(php_only)) - { - if (Z_ISREF_P(val)) - { - msgpack_pack_map(buf, n + 2); - msgpack_pack_nil(buf); - msgpack_pack_long(buf, MSGPACK_SERIALIZE_TYPE_REFERENCE); - } - else - { - msgpack_pack_map(buf, n + 1); - } - - msgpack_pack_nil(buf); - - msgpack_serialize_string(buf, class_name, name_len); - } - else - { - msgpack_pack_array(buf, n); - hash = 0; - } - } + if (MSGPACK_G(php_only)) + { + if (Z_ISREF_P(val)) + { + msgpack_pack_map(buf, n + 2); + msgpack_pack_nil(buf); + msgpack_pack_long(buf, MSGPACK_SERIALIZE_TYPE_REFERENCE); + } + else + { + msgpack_pack_map(buf, n + 1); + } + + msgpack_pack_nil(buf); + + msgpack_serialize_string(buf, class_name, name_len); + } + else + { + msgpack_pack_array(buf, n); + hash = 0; + } } else if (n == 0) { diff --git a/tests/issue023.phpt b/tests/issue023.phpt new file mode 100644 index 0000000..edd0f9b --- /dev/null +++ b/tests/issue023.phpt @@ -0,0 +1,16 @@ +--TEST-- +Issue #23 (Empty objects get serialized with incorrect type) +--SKIPIF-- + +--EXPECTF-- +test Object +( +)