Details
Description
When working with a many to many record, if you toArray then synchronizeWithArray/fromArray the result - you get an exception.
This appears to be due to the fact that toArray returns collections of array(0 => false) (because a record is in a locked state) and fromArray will attempt to link() the refClass (which has multiple identifiers).
Here's a test that should show this behavior:
class Doctrine_Ticket_DC774_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { $this->tables[] = 'EntityAddress'; $this->tables[] = 'Book'; parent::prepareTables(); } public function prepareData() { $user = new User(); $user->name = 'TestUser'; $address = new Address(); $address->address = 'TestAddress'; $user->Addresses[] = $address; $user->save(); } public function testToArraySynchronizeWithManyToMany() { $user = Doctrine_Core::getTable('User')->findOneByName('TestUser'); $user->refreshRelated(); $user->synchronizeWithArray($user->toArray()); } public function testToArrayFromManyToMany() { $user = Doctrine_Core::getTable('User')->findOneByName('TestUser'); $user->refreshRelated(); $user->fromArray($user->toArray()); } }
I doubt this is the right way to fix this, but we wrote in a patch that has the link() function ignore relations that with multiple identifiers. I figured this would be alright since linking those in directly don't make too much sense anyways.
It seems to pass the doctrine test suite. I've attached the patch in case anyone is curious.