-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Merge entity associated to versioned entity #1573
Conversation
try { | ||
$articleMerged = $this->_em->merge($article); | ||
$mergeSucceed = true; | ||
} catch (OptimisticLockException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this try-catch
|
||
/** | ||
* Category constructor. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove this empty line
@@ -1905,6 +1905,18 @@ private function doMerge($entity, array &$visited, $prevManagedCopy = null, $ass | |||
} | |||
|
|||
/** | |||
* Tests if an entity is a non initialized proxy class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be clearer to flip this function and rewrite it as a positive-question, where you're asking if the entity has any data to work with.
private function isLoaded($entity){
return !($entity instanceof Proxy) || $entity->__isInitialized();
}
Other possible names that come to mind are hasData()
or isInitialized()
. (Assuming that non-proxies are considered initialized too.)
*/ | ||
public function __construct() | ||
{ | ||
$this->tags = new ArrayCollection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a public $tags
earlier on?
…nd bi-directional association
…nd bi-directional association
Merged, thanks! Backported also in 2.5.x via 62719f2 |
Great ! |
Also: welcome to this vicious circle of self-slavery called "open source software" ;-) |
I wrote a unit test that reveal the bug and a fix.
If I merge an entity which is associated to a versioned entity this fire a OptimisticLockException as the managedCopy is a Proxy so the version attribute is always null.
I think when we compare version attribute, we should skip it when one of the entity or the managed copy is a Proxy not initialized.