doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.93k stars 2.52k forks source link

DDC-386: UnitOfWork creates an new ArrayCollection and sometimes will pass an object instead of an array in constructor #4711

Closed doctrinebot closed 8 years ago

doctrinebot commented 14 years ago

Jira issue originally created by user marioman:

sometimes will pass an object instead of an array in constructor. \

$actualData[$name] = new ArrayCollection($actualData[$name]);

in this case, you get a

Catchable fatal error: Argument 1 passed to ArrayCollection::_construct() must be an array, object given...

i changed the line 468 with follow lines and works fine, but I'm not sure if this is the best solution!?!?

if (is_object($actualData[$name])) {
  $objc = clone $actualData[$name];
  $actualData[$name] = new ArrayCollection();
  $actualData[$name]->add($objc);
} elseif (is_array($actualData[$name])) {
  $actualData[$name] = new ArrayCollection($actualData[$name]);
} else {
  $actualData[$name] = new ArrayCollection();
}
doctrinebot commented 14 years ago

Comment created by @guilhermeblanco:

I could not reproduce the issue. Tried with one2one, many2one, one2many and many2many with 0, 1 and N records. Nothing caused this.

So, can you please send me how you achieve this issue, like models, DB data and the piece of code that caused this bug?

doctrinebot commented 14 years ago

Comment created by romanb:

Waiting for a reproducable testcase.

doctrinebot commented 14 years ago

Comment created by marioman:

sorry, in the meantime i have refactored my project. in the new version, i don´t get this behave. thx please close this ticket...

doctrinebot commented 14 years ago

Issue was closed with resolution "Cannot Reproduce"