Ticket #1436 (closed defect: fixed)
synchronizeWithArray fails with m:n relations and transient objects
| Reported by: | jasoneisen | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.1.0-ALPHA1 |
| Component: | Record | Version: | 1.0.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | yes | |
| Status: | Pending User Response | Has Patch: | yes |
Description (last modified by jasoneisen) (diff)
Fixes SynchronizeWithArray?() to work with m2m relations. Fixes an already failing test case dealing with this method as well.
Requires an additional argument added to link and unlink to postpone to later, with protected storage vars for pending links and unlinks which are later called by unitofwork on save().
Also fixes unlinking not going ahead and removing references in memory when the keys array is empty.
Usage pasted from test case:
$user = Doctrine_Query::create()->from('User u')->fetchOne();
$userArray = array(
'Group' => array(
'_identifiers' => array(
$this->group_one => '1',
$this->group_two => '1',
$this->group_three => ''
)
));
$user->synchronizeWithArray($userArray);
The protected vars are probably redundant and could be reduced to one, with one getter/setter.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.