Skip to content

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

@emily-dawson

Description

@emily-dawson

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 a05bd84). Attempting to use a non-scalar value in this scenario, as described above, should suffice.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions