Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Cannot Reproduce
-
Affects Version/s: 2.3
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
-
Environment:PHP 5.3 + APC, CentOS
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
Issue Links
- is duplicated by
-
DDC-1987
Cascading "refresh" does not work on lazy loaded associations
-
Activity
Alex
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
<?
// $entity->items is m2m association with (for example) 2 items in it ///////////////////// // 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 |
<?
// $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 |
Alex
made changes -
| 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 |
{code}
// $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 {code} |
Benjamin Eberlei
made changes -
| Attachment | DDC2143Test.php [ 11513 ] |
Benjamin Eberlei
made changes -
| Status | Open [ 1 ] | Awaiting Feedback [ 10000 ] |
Benjamin Eberlei
made changes -
Benjamin Eberlei
made changes -
| Status | In Progress [ 3 ] | Resolved [ 5 ] |
| Resolution | Cannot Reproduce [ 5 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2143, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
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`?