mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Segmentation fault when column have nullable ManyToOne relation #6708
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Nicc0 on GitHub (May 3, 2021).
I created Product entity using PHP8 attributes.
The table was generated correctly, allowing nullable value for column
category_idBut when I trying to add new one entity by
$this->em->persist( $productEntity )console returnsSegmentation fault.It happens only when $category isn't set. (I mean that value is equal
null)Can anyone help me? I would be grateful!
Edit 1:
I noticed that is not a
persistmethod problem, because the error appears after calling the$this->em->commit()method.@Nicc0 commented on GitHub (May 4, 2021):
I found a cause why this problem occurs. During binding parameter
category_idto the insert statement the type is set tointeger, even then category is set tonull. The errorSegmentation faultis returned by original PDO object. I changed locally logic of setting types for columns in/Doctrine/ORM/Persisters/Entity/BasicEntityPersister::prepareUpdateData().I think in this place we should to check
$joinColumnhave a attribute nullable set to true and the value is null also. If yes, set the$columnTypesof current column tonull.@michaljusiega commented on GitHub (May 4, 2021):
Segmentation fault is always returned from PHP, not third-party library.
@Nicc0 commented on GitHub (May 4, 2021):
Can someone link a PullRequest to this issue?
@bibich commented on GitHub (May 6, 2021):
Same issue for me.
using https://github.com/api-platform/api-platform
@windigo00 commented on GitHub (Jun 18, 2025):
Hi. I found out it was caused by wrong annotation of related entities. It happened to me when I had JoinColumn on both sides. Try removing it from one side.