hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

ArrayObject serialization isn't compatible with Zend PHP

Open jmarrama opened this issue 12 years ago • 3 comments

<?php
$a = new ArrayObject();
$a["foo"] = 42;
var_dump(serialize($a));

Zend outputs:

string(60) "C:11:"ArrayObject":36:{x:i:0;a:1:{s:3:"foo";i:42;};m:a:0:{}}"

HHVM outputs:

string(123) "C:11:"ArrayObject":99:{a:3:{s:7:"storage";a:1:{s:3:"foo";i:42;}s:5:"flags";i:0;s:13:"iteratorClass";s:13:"ArrayIterator";}}"

jmarrama avatar Mar 21 '14 21:03 jmarrama

Yeah, we aren't going to be serialize compat with php5. We should be internally consistent with ourselves. We try, but many of our internals differ. Is this breaking your stuff?

ptarjan avatar Mar 21 '14 22:03 ptarjan

Ah, sure. Its not a must fix for me - I can workaround this issue. If I submitted a PR to bring this to parity with Zend would it be accepted? I admit, it is fairly nasty that ArrayObjects aren't serialized like normal objects by spl/Zend.

jmarrama avatar Mar 21 '14 22:03 jmarrama

@jmarrama yup, a PR would be taken, but it is an explicit non-goal to be serialize compat in general.

ptarjan avatar Mar 21 '14 22:03 ptarjan