Skip to content

Commit

Permalink
Merge branch 'hotfix/#1346-post-insert-big-integer-cast-avoidance'
Browse files Browse the repository at this point in the history
Close #1346
  • Loading branch information
Ocramius committed Mar 23, 2015
2 parents 34168d7 + 4c119c4 commit 22d6990
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
class ReadWriteCachedEntityPersister extends AbstractEntityPersister
{
/**
* @param \Doctrine\ORM\Persister\Entity\EntityPersister $persister The entity persister to cache.
* @param \Doctrine\ORM\Cache\ConcurrentRegion $region The entity cache region.
* @param \Doctrine\ORM\EntityManagerInterface $em The entity manager.
* @param \Doctrine\ORM\Mapping\ClassMetadata $class The entity metadata.
* @param \Doctrine\ORM\Persisters\Entity\EntityPersister $persister The entity persister to cache.
* @param \Doctrine\ORM\Cache\ConcurrentRegion $region The entity cache region.
* @param \Doctrine\ORM\EntityManagerInterface $em The entity manager.
* @param \Doctrine\ORM\Mapping\ClassMetadata $class The entity metadata.
*/
public function __construct(EntityPersister $persister, ConcurrentRegion $region, EntityManagerInterface $em, ClassMetadata $class)
{
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ public function executeInserts()
$id = array(
$this->class->identifier[0] => $generatedId
);
$postInsertIds[$generatedId] = $entity;
$postInsertIds[] = array(
'generatedId' => $generatedId,
'entity' => $entity,
);
} else {
$id = $this->class->getIdentifierValues($entity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ public function executeInserts()
$id = array(
$this->class->identifier[0] => $generatedId
);
$postInsertIds[$generatedId] = $entity;
$postInsertIds[] = array(
'generatedId' => $generatedId,
'entity' => $entity,
);
} else {
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,9 @@ private function executeInserts($class)

if ($postInsertIds) {
// Persister returned post-insert IDs
foreach ($postInsertIds as $id => $entity) {
foreach ($postInsertIds as $postInsertId) {
$id = $postInsertId['generatedId'];
$entity = $postInsertId['entity'];
$oid = spl_object_hash($entity);
$idField = $class->identifier[0];

Expand Down
5 changes: 4 additions & 1 deletion tests/Doctrine/Tests/Mocks/EntityPersisterMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public function addInsert($entity)
if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY
|| $this->class->isIdGeneratorIdentity()) {
$id = $this->identityColumnValueCounter++;
$this->postInsertIds[$id] = $entity;
$this->postInsertIds[] = array(
'generatedId' => $id,
'entity' => $entity,
);
return $id;
}
return null;
Expand Down
Loading

0 comments on commit 22d6990

Please sign in to comment.