Skip to content

fix(serializer): leave IRI-referenced translations to native denormalization#83

Merged
paullla merged 1 commit into
Locastic:masterfrom
paullla:fix/iri-translations-passthrough
Jul 7, 2026
Merged

fix(serializer): leave IRI-referenced translations to native denormalization#83
paullla merged 1 commit into
Locastic:masterfrom
paullla:fix/iri-translations-passthrough

Conversation

@paullla

@paullla paullla commented Jul 7, 2026

Copy link
Copy Markdown
Member
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Issues relates to #40
License MIT

Problem

TranslatableItemDenormalizer (new in 2.0.0) claims every payload whose translations key is an array, including a list of IRI strings, the shape used when translations are exposed as their own ApiResource (as in #40). It then skips the string items, so the references are silently dropped on POST and PATCH, and PUT removes every existing translation because no submitted locale is recorded. Before 2.0.0, API Platform resolved such IRIs natively.

Changes

  • Restrict supportsDenormalization to the embedded shape (every item a document): IRI lists and mixed payloads take the native denormalization path again, restoring the pre-2.0 behavior for that shape.
  • Keep the in-loop skip of non-array items as defense for direct denormalize() calls.
  • Unit test pinning the pass-through for IRI lists and mixed payloads; CHANGELOG entry under Unreleased.

Verification

  • New test fails on 2.0.0 (the denormalizer claims the IRI-list payload) and passes with the fix.
  • bin/phpunit: 66 tests, 131 assertions, green (9 pre-existing deprecations).
  • bin/phpstan analyse --memory-limit=512M: no errors (level 6).
  • bin/php-cs-fixer check: no violations.
  • composer validate --strict: valid.

…ization

TranslatableItemDenormalizer claimed every payload whose translations
key was an array, including a list of IRI strings (translations exposed
as their own ApiResource, as in Locastic#40). It then skipped the string items,
so the references were silently dropped on POST and PATCH, and PUT
removed every existing translation because no submitted locale was
recorded. Before 2.0.0 API Platform resolved such IRIs natively.

Restrict supportsDenormalization to the embedded shape (every item a
document): IRI lists and mixed payloads now take the native path again,
restoring the pre-2.0 behavior for that shape. The in-loop skip stays as
defense for direct denormalize() calls.
@paullla paullla merged commit 1070801 into Locastic:master Jul 7, 2026
6 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