Bug #43967
Error in evaluating orphanRemoval in Flow Annotation driver
Status:
New
Priority:
Should have
Assignee:
-
Category:
Persistence
Target version:
-
Start date:
2012-12-13
Due date:
% Done:
0%
Estimated time:
PHP Version:
Has patch:
No
Complexity:
easy
Description
There is what I consider an error in the code that evaluates the orphanRemoval flag.
The code is the following (I renumbered the rows for convenience):
1. if ($oneToManyAnnotation->orphanRemoval) { 2. $mapping['orphanRemoval'] = $oneToManyAnnotation->orphanRemoval; 3. } elseif ($this->isAggregateRoot($mapping['targetEntity'], $className) === FALSE) { 4. $mapping['orphanRemoval'] = TRUE; 5. }
In my opinion row 1 should be instead:
1. if (isset($oneToManyAnnotation->orphanRemoval)) {
Otherwise the fact of not being an aggregate root would make the orphanRemoval flag always
TRUE despite of the value of the annotation specified on the attribute.
This is especially true because the orphanremoval attribute is of type boolean.
Moreover, in my opinion, other similar lines like:
if ($oneToOneAnnotation->cascade) {
would be more clearly and safely written as:
if (isset($oneToOneAnnotation->cascade)) {
Files
Updated by Tarcisio Fedrizzi about 8 years ago
Adding the patch that fixes the orphanRemoval issue.
As said in the initial post, in my opinion, other checks
would be better written explicitly rather than relying
upon PHP boolean conversion.