-
-
Notifications
You must be signed in to change notification settings - Fork 509
Fix/1497 #1498
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
Fix/1497 #1498
Conversation
@@ -540,6 +540,7 @@ public function clear() | |||
} | |||
|
|||
if ($this->isOrphanRemovalEnabled()) { | |||
$this->initialize(); |
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.
It still won't execute due to the $this->initialized
you pointed out earlier. At first glance I would just remove $this->initialized
from if
, but I did not read further down the code to be sure.
I believe that if you're calling clear
, then you want the collection to be cleared regardless if it was already initialized or not though.
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.
If collection is not initialized then if
statements will evaluate to false
thus reaching this point
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.
Damn, true ;)
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'v made two commits so you can see the test failing and then not failing any more with the fix commit. In the bug-case $this->initialized
is false, so the code after the if
IS executed :). Removing the $this->initialized
check & not inserting the $this->initialize()
line cause the test to fail again. It looks like $this->isEmpty()
is not (implicitly) triggering initialization either.
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.
It looks like
$this->isEmpty()
is not (implicitly) triggering initialization either.
You are correct. isEmpty
uses the count
method defined in PersistentCollectionTrait
if the collection is not initialized, which again does not initialize the collection (because it doesn't need to).
I'v reset & reapplied it from 1.1.x. I'v also made a PR from 1.0.x #1500 |
Failing test (1. commit) and fix (2. commit)