I try to explain through an example.
User — UserGroup — Group // many-to-many relation
So _pendingUnlinks[$alias] will be an array.
Then fromArray() calls link() in line 1949:
link() remove new IDs (1, 2 and 3) from _pendingUnlinks[$alias] in line 2496:
So _pendingUnlinks[$alias] will be an empty array.
When we save user, this code is executed in Doctrine_Connection_UnitOfWork::saveGraph() (in line 103):
Because _pendingUnlinks[$alias] is an empty array, neither IF branch will be executed, so relations won't be deleted.
And then Doctrine try to insert new relations, but it will fail because it will violate existed primary keys in UserGroup.
In an earlier version of Doctrine-1.2, the unlink() method set _pendingUnlinks[$alias] to false if $ids attribute was an empty array, so in saveGraph() all relations were deleted before new relations inserted.
/Sorry for my poor English/