-
-
Notifications
You must be signed in to change notification settings - Fork 926
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
Conversation
This looks like it breaks one of our test would you be able to identify why? Inside |
{ | ||
$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.
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?
Hello, thanks for taking a look. Yep I'll get that sorted! |
d204102
to
81a393f
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! |
Hi @soyuka - is the approach good? is there anything else necessary to get this merged (there's only one failing check, it's from php-cs-fixer in unrelated files, so I've left them as they are, per the contributing.md)? Sorry to nudge but I just want to check if this PR is still being looked at and not forgotten about. 🙂 |
Thanks @calbro7 ! |
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!