From cb52782e5e987f35ee16edd148328fed0b17b3da Mon Sep 17 00:00:00 2001
From: Asmir Mustafic <goetas@gmail.com>
Date: Tue, 3 Feb 2015 00:11:42 +0100
Subject: [PATCH] Default Version Value identifier is always an array

---
 .../Entity/BasicEntityPersister.php           | 19 +++++++++----------
 .../Entity/JoinedSubclassPersister.php        |  9 ++++++---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
index f85aedfaf..a1d1969a8 100644
--- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
+++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
@@ -281,8 +281,11 @@ class BasicEntityPersister implements EntityPersister
             $stmt->execute();
 
             if ($isPostInsertId) {
-                $id = $idGenerator->generate($this->em, $entity);
-                $postInsertIds[$id] = $entity;
+                $generatedId = $idGenerator->generate($this->em, $entity);
+                $id = array(
+                    $this->class->identifier[0] => $generatedId
+                );
+                $postInsertIds[$generatedId] = $entity;
             } else {
                 $id = $this->class->getIdentifierValues($entity);
             }
@@ -304,11 +307,11 @@ class BasicEntityPersister implements EntityPersister
      * entities version field.
      *
      * @param object $entity
-     * @param mixed  $id
+     * @param array  $id
      *
      * @return void
      */
-    protected function assignDefaultVersionValue($entity, $id)
+    protected function assignDefaultVersionValue($entity, array $id)
     {
         $value = $this->fetchVersionValue($this->class, $id);
 
@@ -319,11 +322,11 @@ class BasicEntityPersister implements EntityPersister
      * Fetches the current version value of a versioned entity.
      *
      * @param \Doctrine\ORM\Mapping\ClassMetadata $versionedClass
-     * @param mixed                               $id
+     * @param array                               $id
      *
      * @return mixed
      */
-    protected function fetchVersionValue($versionedClass, $id)
+    protected function fetchVersionValue($versionedClass, array $id)
     {
         $versionField   = $versionedClass->versionField;
         $tableName      = $this->quoteStrategy->getTableName($versionedClass, $this->platform);
@@ -335,10 +338,6 @@ class BasicEntityPersister implements EntityPersister
              . ' FROM '  . $tableName
              . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';
 
-        if (!is_array($id)) {
-            $id = array($this->class->identifier[0] => $id);
-        }
-
         $flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id);
 
         $value = $this->conn->fetchColumn($sql, array_values($flatId));
diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php
index a5bd84348..d4159ce47 100644
--- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php
+++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php
@@ -176,8 +176,11 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
             $rootTableStmt->execute();
 
             if ($isPostInsertId) {
-                $id = $idGenerator->generate($this->em, $entity);
-                $postInsertIds[$id] = $entity;
+                $generatedId = $idGenerator->generate($this->em, $entity);
+                $id = array(
+                    $this->class->identifier[0] => $generatedId
+                );
+                $postInsertIds[$generatedId] = $entity;
             } else {
                 $id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
             }
@@ -572,7 +575,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
     /**
      * {@inheritdoc}
      */
-    protected function assignDefaultVersionValue($entity, $id)
+    protected function assignDefaultVersionValue($entity, array $id)
     {
         $value = $this->fetchVersionValue($this->getVersionedClassMetadata(), $id);
         $this->class->setFieldValue($entity, $this->class->versionField, $value);