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

Closed
opened 2026-01-22 12:39:54 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 2, 2010).

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();
}
Originally created by @doctrinebot on GitHub (Mar 2, 2010). 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(); } ```
admin added the Improvement label 2026-01-22 12:39:54 +01:00
admin closed this issue 2026-01-22 12:39:54 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 3, 2010):

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 on GitHub (Mar 3, 2010): 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?
Author
Owner

@doctrinebot commented on GitHub (Mar 30, 2010):

Comment created by romanb:

Waiting for a reproducable testcase.

@doctrinebot commented on GitHub (Mar 30, 2010): Comment created by romanb: Waiting for a reproducable testcase.
Author
Owner

@doctrinebot commented on GitHub (Apr 8, 2010):

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 on GitHub (Apr 8, 2010): 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...
Author
Owner

@doctrinebot commented on GitHub (Apr 8, 2010):

Issue was closed with resolution "Cannot Reproduce"

@doctrinebot commented on GitHub (Apr 8, 2010): Issue was closed with resolution "Cannot Reproduce"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#481