Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check for non-nullable property when deleting a record #8065

Closed
wants to merge 4 commits into from

Conversation

joaojacome
Copy link

@joaojacome joaojacome commented Mar 10, 2020

Solves #7999

@joaojacome joaojacome changed the title Added check for non-nullable property when deleting a record #7999 Added check for non-nullable property when deleting a record Mar 10, 2020
@beberlei
Copy link
Member

This needs to be fixed in doctrine/persistence instead. We already have a TypedNoDefaultReflectionProperty overwrite for ReflectionProperty there and it only needs an addition to setValue() to handle the NULL case as unset(). The problem is your unset() code here only works on public properties, it will cause an error on protected or private ones.

A workaround needs to be found to unset any kind of visibility property. The following is a prototype using closure and binding to this, but it doesn't seem to work: https://gist.github.com/beberlei/f28142a1b15f011bbcd0156c7aa64430

@beberlei beberlei closed this Mar 15, 2020
@beberlei
Copy link
Member

Have the right approach thanks to @lcobucci now, updated the gist.

@prof-web-coding
Copy link

@joaojacome Will you update the code according to @beberlei 's input?

@joaojacome
Copy link
Author

joaojacome commented Mar 19, 2020

@joaojacome Will you update the code according to @beberlei 's input?

I could, but I think @beberlei fixed it here: doctrine/reflection#34

@prof-web-coding
Copy link

prof-web-coding commented Mar 19, 2020

Thanks. It does not work for me. I have a private int $id; in an Doctrine\ORM\Mapping\Entity and I'm gettingError: Cannot access private property xxx::$id. It seems that the newly added setValue in doctrine/reflection#34 is not called, with or without 23b57f6

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.

None yet

3 participants