[DDC-2143] $em->refresh($entity) doesn't refresh associations cleared with clear() Created: 14/Nov/12 Updated: 01/May/13 Resolved: 01/May/13 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Alex | Assignee: | Benjamin Eberlei |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3 + APC, CentOS |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
// $entity->items is m2m association ///////////////////// // 1. Bug echo $entity->items->count(); // 2 $entity->items->clear(); echo $entity->items->count(); // 0 $em->refresh($entity); echo $entity->items->count(); // 0 <-- ??? ////////////////// // 2. Workaround echo $entity->items->count(); // 2 // remove items one by one $items = $entity->items->toArray(); foreach ( $items as $item ) { $entity->items->removeElement($item); } echo $entity->items->count(); // 0 $em->refresh($entity); echo $entity->items->count(); // 2, as expected |
| Comments |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
This is because `clear` on an un-initialized collection doesn't initialize it. Can you confirm this by adding a call to $this->initialize()
in the `clear` method of `Doctrine\ORM\PersistentCollection`? |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
Related to |
| Comment by Marco Pivetta [ 21/Feb/13 ] |
|
Alex ping? |
| Comment by Benjamin Eberlei [ 31/Mar/13 ] |
|
I cannot reproduce this issue, see the testscript attached (put into tests/Doctrine/Tests/ORM/Functional/Ticket/). Can you try to make this code fail? |
| Comment by Benjamin Eberlei [ 01/May/13 ] |
|
Closed, no feedback. |