ramsey / uuid-doctrine

:snowflake::file_cabinet: Allow the use of a ramsey/uuid UUID as Doctrine field type.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incompatibility with ramsey/uuid 4.1

janlanger opened this issue · comments

The UuidBinaryOrderedTimeType is incompatible with latest ramsey/uuid 4.1, when using Doctrine Second Level cache. Uuid loaded from DB has type Ramsey\Uuid\Rfc4122\UuidV1, but when this type is serialized/deserialized (in caching), type conversion fails with Could not convert database value "11ead339-8a48-dd88-a..." to Doctrine Type uuid_binary_ordered_time. Expected format: UuidV1

Sample:

$uuid = Uuid::uuid1();
$type = new UuidBinaryOrderedTimeType();
$platform = new MySQL80Platform();

var_dump(get_class($uuid), $uuid->getVersion()); //LazyUuidFromString, 1
$dbValue = $type->convertToDatabaseValue($uuid, $platform);
$phpValue = $type->convertToPHPValue($dbValue, $platform);

var_dump(get_class($phpValue), $phpValue->getVersion()); // Rfc4122\UuidV1, 1

$unserialized = unserialize(serialize($phpValue));  // simulating uuid loaded from cache

var_dump(get_class($unserialized), $unserialized->getVersion()); // Rfc4122\UuidV1, NULL
$type->convertToDatabaseValue($unserialized, $platform); // throws exception

Probably related to ramsey/uuid#324, not sure if it is issue there or here...

Thanks for reporting. This is related to ramsey/uuid#327

which version of the the library are you using ?

@stof the issue is on uuid:4.1 with uuid-doctrine:1.6

see if the discussion in ramsey/uuid#329 helps

Upgrading to ramsey/uuid 4.2 should fix this. If not, please let me know.