Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2143

$em->refresh($entity) doesn't refresh associations cleared with clear()

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical 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

          Activity

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Alex
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: