-
-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialized UUIDs don't store codec information #259
Comments
This is correct, and it's been an issue for a long time, though it's never been discussed here. I'm going to mark it as a bug because I'd like to come up with a solution for it. Additionally, when UUIDs using alternate codecs to shift their bits around are stored as bytes in databases, for example, there's no information stored within them to note that they have been modified and must be decoded using the proper codec. |
Hi, After that upgrade app has started throwing error on UUID unserialize (when Symfony tries to unserialize session data). Error:
How to reproduce: $factory = new UuidFactory();
$factory->setCodec(new OrderedTimeCodec(
$factory->getUuidBuilder()
));
Uuid::setFactory($factory);
$uuid = Uuid::fromString('211a3b1e-928f-11ed-b52d-0242ac12000b');
$serializedUuid = serialize($uuid);
$unserializedUuid = unserialize($serializedUuid); I have noticed that issue is somewhat related to if ($this->codec instanceof OrderedTimeCodec) {
$bytes = $this->getFields()->getBytes();
$rearrangedBytes = $bytes[6] . $bytes[7]
. $bytes[4] . $bytes[5]
. $bytes[0] . $bytes[1] . $bytes[2] . $bytes[3]
. substr($bytes, 8);
return $rearrangedBytes;
} This rearranges bytes before serialization and on unserialize Not sure if this is related to first issue, if not I can open separate issue. |
To reproduce:
The text was updated successfully, but these errors were encountered: