Comments (9)
What about this bug? It's pretty important for me. Without fix we can't use msgpack as serialization format to exchange data between different programming environments.
from msgpack-php.
<?php
class Test {
private $privateProperty = 'some value';
protected $protectedProperty = 'some value';
public $property = 'some value';
public function toArray() {
return get_object_vars($this);
}
}
$o = new Test();
$msgpack = new MessagePack(false);
print_r($msgpack->unpack($msgpack->pack($o->toArray())));
Array
(
[privateProperty] => some value
[protectedProperty] => some value
[property] => some value
)
from msgpack-php.
I can do it via reflection. But I think it's not a right way to do serialization using serialization tool :)
from msgpack-php.
what about in the way: https://github.com/kjdev/php-ext-msgpacki
$o = new Test();
$msgpack = new MessagePacki(MSGPACKI_MODE_ORIGIN);
print_r($msgpack->unpack($msgpack->pack($o)));
/*
Output:
Array
(
[privateProperty] => some value
[protectedProperty] => some value
[property] => some value
)
*/
$msgpack = new MessagePacki(MSGPACKI_MODE_PHP);
print_r($msgpack->unpack($msgpack->pack($o)));
/*
Output:
Test Object
(
[privateProperty:Test:private] => some value
[protectedProperty:protected] => some value
[property] => some value
)
*/
from msgpack-php.
@kjdev I use it right now (btw good work!) :) But even when I use msgpacki there is still a bug in "official" msgpack extension for php. Maybe it's time to change that on msgpack site and add some english docs for your library?
http://msgpack.org/
from msgpack-php.
bump - I'm hitting this issue under php 5.6 as well
from msgpack-php.
@jippi Hi!
Thanks for bumping this, I am working my way through the backlog. I will add a failing test for this tonight, and work on fixing this.
However, I worry that people are depending on the current broken behavior so I don't know what to do about that. @laruence opinions?
To get you up and running right now, @laruence's solution should work for you right away!
from msgpack-php.
@Sean-Der The current behavior is quite odd, find it hard to see if anyone is actually depending on it
Alternative, implement it as a MSGPACK_SERIALIZE_ASSOC kind of flag and let it be off by default, and switch to ON at some point when you break something other? :)
Our payloads are deeply nested arrays and objects, so I would have to traverse everything by hand and forcing it to array.
Idealy for me, it would serialize to the same array structure as json_encode($object) does - that would allow for custom per-class callback for serialization etc as well - basically using https://wiki.php.net/rfc/jsonserializable :)
Our hack today is to json_encode and the msgpack it :)
from msgpack-php.
using 0.5.7-1 (remi's repo on a centos6). using msgpack as session data serialization handler (binary AND multilang, yay!) as i need the session data available in node as well. using php_only = false to be on the safe side. phpmyadmin stops working, the geniuses store entire system objects in the session (like the theme object), now stuck between a rock (phpmyadmin is needed for obvious reasons) and a hard place (php_only = false still converts objects to arrays, but i need session data in other languages).
question: if, in my application, i avoid using objects in my session data (i use assoc arrays instead), can i switch php_only = true so that phpmyadmin starts working again, yet still have the ability to use session data from php in node? in essence, is a php_only = true encoded session data usable in other languages if i keep away from storing objects in it?
from msgpack-php.
Related Issues (20)
- Unable to compile with PHP 7.4.0 on macOS 10.15.1 HOT 6
- 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
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.