Description
API Platform version(s) affected: 3.3.2
Description
I noticed that in PR #6102 was added feature to clone original data
in Symfony WriteListener. This orignal data
are further used to generate Content-Location header.
However when someone already use __clone() on Entity (original data object) to provide some other bussiness functionality and resets id
property (for example):
public function __clone()
{
$this->id = null;
}
Generating Content Location header fails with Metadata RuntimeException No identifier value found, did you forget to persist the entity?
How to reproduce
Simple GET /api/entity/{id}
with __clone() method setting ID property to null results to RuntimeException
Of course, this issue applies only for Symfony (use_symfony_listeners: true
)
Possible Solution
I'm not sure why is cloning original data
even needed.