-
-
Notifications
You must be signed in to change notification settings - Fork 922
fix(serializer): Allow nested denormalization when allow_extra_attributes=false #7270
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
base: 4.1
Are you sure you want to change the base?
Conversation
{ | ||
$allowedAttributes = parent::getAllowedAttributes($classOrObject, $context, $attributesAsString); | ||
if (\is_array($allowedAttributes) && ($context['api_denormalize'] ?? false)) { | ||
$allowedAttributes = array_merge($allowedAttributes, ['id']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if id
isn't the property/attribute used to identify a resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, possibly I'm misunderstanding what you mean, I think it always will be id
, as it's not configurable is it? And it's also hardcoded eg here:
private function updateObjectToPopulate(array $data, array &$context): void
{
try {
$context[self::OBJECT_TO_POPULATE] = $this->iriConverter->getResourceFromIri((string) $data['id'], $context + ['fetch_data' => true]);
When/how could it be something else?
This looks like it breaks one of our test would you be able to identify why? Inside |
Hello, thanks for taking a look. Yep I'll get that sorted! |
52855fa
to
2f5e491
Compare
This was because with my changes then there were some scenarios where I've fixed this by unsetting Let me know if this approach is good or if I'm overlooking any problems! All the github checks are successful apart from the commit linting, could you advise what's wrong with it because I'm not sure? |
The linked issue was resolved for JSON LD format with #6451 but not for standard JSON, so this PR implements the same change in the standard ItemNormalizer.
The included test file demonstrates the expected behaviour, it should be possible to alter the Bar entity's
someProperty
via a PATCH request to edit its parentFoo
object.This test passes with the ItemNormalizer change, but fails without it due to
Extra attributes are not allowed (\"id\" is unknown).
.First contribution so let me know if I've done things correctly or if I've missed anything needed for approval!