Comments (10)
Hey @rybakit
So AFAIK the zend engine API shouldn't care about order. While they are stored as a list, I do not think the position+key matters.
However, zero length keys does seem edge casey to me (I know we do have tests for this though)
I am debugging this now, and will update it when I know more.
What value are you expecting back after deserialization? If you are encoding/decoding in multiple languages you should also be setting PHPONLY to false, then you will end up with the following
$msgpack = new MessagePack();
$msgpack->setOption(MessagePack::OPT_PHPONLY, false);
var_dump($msgpack->unpack( hex2bin('82c0a8737464436c617373a3666f6fa3626172')));
var_dump($msgpack->unpack( hex2bin('82a3666f6fa3626172c0a8737464436c617373')));
----
Warning: [msgpack] (msgpack_unserialize_map_item) illegal key type in /home/vagrant/code/msgpack-php/test.php on line 5
array(2) {
[""]=>
string(8) "stdClass"
["foo"]=>
string(3) "bar"
}
Warning: [msgpack] (msgpack_unserialize_map_item) illegal key type in /home/vagrant/code/msgpack-php/test.php on line 6
array(2) {
["foo"]=>
string(3) "bar"
[""]=>
string(8) "stdClass"
}
Or are you looking to create PHP objects via input crafted from Lua? While possible, that is certainly an undefined behavior. Looking at the code it could be done, but would be expensive once you hit the null key (containing the class name) you would then have to copy your half serialized object to the new object. If you are really stuck I can look into making this work for you, but you are depending on funky behavior.
from msgpack-php.
Hey @Sean-Der, thanks for the quick response.
I'm trying to get back a php object. The combo looks like this:
$packer = new MessagePack(true);
$packed = $packer->pack((object) ['foo' => 'bar']);
// 0x82c0a8737464436c617373a3666f6fa3626172
Then the packed data goes through Lua:
unpacked = msgpack.decode(packed)
packed = msgpack.encode(unpacked)
-- 0x82a3666f6fa3626172c0a8737464436c617373
And returns to php:
$obj = $packer->unpack($packed);
var_dump($obj);
// class stdClass#3 (0) {}
from msgpack-php.
would be expensive once you hit the null key (containing the class name) you would then have to copy your half serialized object to the new object.
What if you serialize an object into indexed array ['stdClass', ['foo' => 'bar']]
? This will guarantee the same order across different languages, but introduce a BC break and I donβt know if itβs worth it. Or store the data into a temporary structure before building an object?
If you are really stuck I can look into making this work for you, but you are depending on funky behavior.
I try to figure out first what is possible in my case. If you say that it will be funky to support the object serialization, then I will probably just drop supporting objects in my code.
from msgpack-php.
Hey @rybakit try 488779b for PHP5 and 116cc56 for PHP7
from msgpack-php.
Works like a charm π Thank you!
from msgpack-php.
Awesome! Now I just need some tests. Hand crafting these would not be fun, is there anything special you did to make your test values? I just want to make test values for
- Multiple properties
- Some before/some after so the empty key is in the middle
- All datatypes strings/numbers/arrays/objects
thanks!
from msgpack-php.
from msgpack-php.
Thank you so much @rybakit , I owe you big time π I am gonna go grok the tests and the merge them thank you so much!
from msgpack-php.
Happy to help, and thank you too ;)
from msgpack-php.
@Sean-Der @laruence Looks like the fix for this issue is not present in the latest versions (neither 0.5.7 nor 2.0.0). Do you plan to create a new tag with the fix anytime soon?
from msgpack-php.
Related Issues (20)
- Recursion encoded as NULL
- 034.phpt fails HOT 1
- Consider making MessagePackUnpacker cloneable
- Memory Consumption Problem in 2.1.0 HOT 1
- msgpack (un)pack error HOT 11
- try to compile from source by zts-phpize HOT 2
- php_add_session_var: symbol not found HOT 1
- More and more memory, there seems to be a leak HOT 1
- PHP 8 recursion
- my code is printed ,but out to show the garbled code, why? HOT 2
- How to get in touch about a security issue? HOT 2
- Support PHP 8.1's ZEND_ACC_NOT_SERIALIZABLE flag on zend_class_entries
- uint32 numbers are incorrectly serialized on Windows HOT 1
- PHP 8.2 - msgpack_check_ht_is_map assertion error in ZEND_HASH_FOREACH_BUCKET
- PHP 8.2: msgpack_unpack: Support deprecation of dynamic properties, forbid dynamic properties in `readonly` classes HOT 1
- MsgPack TS non TS fail HOT 5
- Compilation error reported HOT 3
- Question: release 2.2.0
- Serializing/Unserializing Enum
- Windows DLL available to download
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgpack-php.