Skip to content

fix(laravel): persist dirty embedded belongsTo relations#8246

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/laravel-embedded-relations-6882
Jun 5, 2026
Merged

fix(laravel): persist dirty embedded belongsTo relations#8246
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/laravel-embedded-relations-6882

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 5, 2026

Summary

PATCH requests targeting an embedded BelongsTo/MorphTo relation silently dropped attribute changes: the persistor only called save() on new relations, never on dirty ones. Save on new || dirty so denormalized modifications propagate.

Reproduction

PATCH a CartItem with a nested shoppingCart payload containing an updated userIdentifier — the parent cart was not updated.

Test plan

  • Added failing test covering the bug.
  • Test passes after the fix.
  • Related Laravel tests still pass locally.

Fixes #6882

Previously, PersistProcessor only saved the related model when it did not
yet exist. For PATCH requests using deep_object_to_populate, an embedded
relation already existed but its attributes had been modified; those
changes were silently dropped. Save when the relation is new or dirty so
denormalized changes propagate.

Fixes api-platform#6882
@soyuka soyuka force-pushed the fix/laravel-embedded-relations-6882 branch from 1fadf3f to 09543f3 Compare June 5, 2026 08:47
@soyuka soyuka merged commit f4d2b56 into api-platform:4.3 Jun 5, 2026
110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant