mezzio-hal icon indicating copy to clipboard operation
mezzio-hal copied to clipboard

Broken self links when using RouteBasedResourceStrategy with resource identifiers that are objects

Open emily-dawson opened this issue 4 years ago • 0 comments

BC Break Report

Q A
Version 1.4.0

Summary

When using RouteBasedResourceStrategy, the generated self link for individual HAL resources is broken when the resource identifier references a property that contains an object, regardless of whether the object can be represented as a scalar value. In my specific case, I am using the ramsey/uuid-doctrine library which represents the ID as an object once the entity is hydrated with data from the database.

Previous behavior

Due to this library not previously checking explicitly for scalar values in RouteBasedResourceStrategy::createResource, and the UUID objects employing __toString (and other serialisation methods), the UUID object was accepted and the self links were generated as expected.

Current behavior

The property value of a mapped resource containing such an object is not passed through as a route parameter in RouteBasedResourceStrategy::createResource like it was before, resulting in the self link being broken. After updating from 1.3.1 to 1.4.0, all the self links are showing paths such as /some-resource/%7Bid%7D, instead of the value of the field (e.g. /some-resource/1b7e838c-5758-11eb-b1fe-0242281aebdd).

How to reproduce

It seems like this was a change specifically made as a result of a test in this library (commit a05bd845bc1180116c0ee15db46c7b95d302afa7). Attempting to use a non-scalar value in this scenario, as described above, should suffice.

emily-dawson avatar Jan 15 '21 18:01 emily-dawson