Skip to content

Removing a resource's translation via API platform causes 500 error due to property accesor #1009

@mart-insiders

Description

@mart-insiders

Sylius version affected: 1.13.0-ALPHA.3

Description
When removing a translation in combination with Symfony's property accessor component in a standard API platform PUT operation, crashes because of the Assert::notNull($translatable); check.

Steps to reproduce
Standard API platform configuration for a resource with a Put configuration and 'standard_put' => true, configured.
Define the resource as a Sylius resource with a translation.
Add the OneToMany with cascade options and orphanRemoval #[ORM\OneToMany(mappedBy: 'translatable', targetEntity: AreaTranslation::class, cascade: ['persist', 'remove'], orphanRemoval: true, indexBy: 'locale')]
Define the translation resource as an API platform resource.
Update a resource which has 2 translations, to remove one translation.
Api platforms PurgeHttpCacheListener checks if it can read the property translatable using symfony's property accessor.
When trying to return its value it throws the 500 due to the Assert::notNull($translatable)

Possible Solution
make the getter in the translationInterface nullable?
public function getTranslatable(): ?TranslatableInterface

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions