mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
cascade="all" will always give errors, cascade={"all"} will work #1044
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 @daarribas on GitHub (Oct 25, 2010).
The doctrine 2.0 documentation clearly states that it is possible to use the exact statement cascade="ALL" within relationship annotations.
E.g. here: http://www.doctrine-project.org/projects/orm/2.0/docs/reference/annotations-reference/en
But when actually used like that, it will result in PHP warnings as soon as metadata is read, and the cascade will actually not be processed. This can result in all sorts of weird error conditions with error texts like "A new entity was found through a relationship that was not configured to cascade persist operations", because it will actually not respect the cascade declared.
The warnings are:
in_array() expects parameter 2 to be array, string given in ... Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 735
in_array() expects parameter 2 to be array, string given in ... Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 745
in_array() expects parameter 2 to be array, string given in ... Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 746
in_array() expects parameter 2 to be array, string given in ... Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 747
in_array() expects parameter 2 to be array, string given in ... Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 748
in_array() expects parameter 2 to be array, string given in ... Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 749
These are obviously due to this block of code in ORM/Mapping/ClassMetadataInfo:735
changing the annotation to cascade="{all"} fixes the problem, because then it is technically an array, as it would be with, say, cascade={"persist", "remove"}.
I am using the DefaultAnnotationDriver.
I consider this broken, because it does not behave as documented. More than that, the documentation actually tells people to do it wrongly.
@beberlei commented on GitHub (Oct 31, 2010):
Can you move this issue to www.doctrine-project.org/jira ? we dont use this tracker here and i will disable it soonish.