Bug #43967
Error in evaluating orphanRemoval in Flow Annotation driver
Status: | New | Start date: | 2012-12-13 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | Persistence | |||
Target version: | - | |||
PHP Version: | Complexity: | easy | ||
Has patch: | No | Affected Flow version: | (any) |
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)) {
History
#1 Updated by Tarcisio Fedrizzi over 2 years ago
- File orphanRemoval-fix-driver-check.patch added
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.