Skip to content

Commit

Permalink
fix: Missing orphanRemoval: true on non-nullable OneToMany relation…
Browse files Browse the repository at this point in the history
…ships
  • Loading branch information
roadiz-ci committed Mar 18, 2024
1 parent 01e89d7 commit b7bf6ed
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/Entity/CustomForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ class CustomForm extends AbstractDateTimed
* @var Collection<int, CustomFormField>
*/
#[
ORM\OneToMany(mappedBy: "customForm", targetEntity: CustomFormField::class, cascade: ["ALL"]),
ORM\OneToMany(
mappedBy: "customForm",
targetEntity: CustomFormField::class,
cascade: ["ALL"],
orphanRemoval: true
),
ORM\OrderBy(["position" => "ASC"]),
Serializer\Groups(["custom_form"]),
SymfonySerializer\Groups(["custom_form"]),
Expand All @@ -123,7 +128,8 @@ class CustomForm extends AbstractDateTimed
ORM\OneToMany(
mappedBy: "customForm",
targetEntity: CustomFormAnswer::class,
cascade: ["ALL"]
cascade: ["ALL"],
orphanRemoval: true
),
Serializer\Exclude,
SymfonySerializer\Ignore
Expand Down
3 changes: 2 additions & 1 deletion src/Entity/CustomFormAnswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class CustomFormAnswer extends AbstractEntity
ORM\OneToMany(
mappedBy: "customFormAnswer",
targetEntity: CustomFormFieldAttribute::class,
cascade: ["ALL"]
cascade: ["ALL"],
orphanRemoval: true
),
Serializer\Groups(["custom_form_answer"]),
SymfonySerializer\Groups(["custom_form_answer"])
Expand Down
7 changes: 6 additions & 1 deletion src/Entity/NodeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ class NodeType extends AbstractEntity implements NodeTypeInterface
* @var Collection<int, NodeTypeField>
*/
#[
ORM\OneToMany(mappedBy: "nodeType", targetEntity: NodeTypeField::class, cascade: ["all"]),
ORM\OneToMany(
mappedBy: "nodeType",
targetEntity: NodeTypeField::class,
cascade: ["all"],
orphanRemoval: true
),
ORM\OrderBy(["position" => "ASC"]),
Serializer\Groups(["node_type"]),
SymfonySerializer\Groups(["node_type"]),
Expand Down
7 changes: 6 additions & 1 deletion src/Model/AttributeGroupTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ trait AttributeGroupTrait
* @var Collection<int, AttributeGroupTranslationInterface>
*/
#[
ORM\OneToMany(mappedBy: "attributeGroup", targetEntity: AttributeGroupTranslationInterface::class, cascade: ["all"]),
ORM\OneToMany(
mappedBy: "attributeGroup",
targetEntity: AttributeGroupTranslationInterface::class,
cascade: ["all"],
orphanRemoval: true
),
Serializer\Groups(["attribute_group", "attribute", "node", "nodes_sources"]),
Serializer\Type("ArrayCollection<RZ\Roadiz\CoreBundle\Model\AttributeGroupTranslationInterface>"),
Serializer\Accessor(getter: "getAttributeGroupTranslations", setter: "setAttributeGroupTranslations")
Expand Down

0 comments on commit b7bf6ed

Please sign in to comment.