From d0419782bd2eacada1ea0ba0adf3748932b9486b Mon Sep 17 00:00:00 2001
From: Benjamin Eberlei <kontakt@beberlei.de>
Date: Thu, 14 Mar 2013 23:19:58 +0100
Subject: [PATCH] [DDC-2300] Fix version xml mapping and serialization of
 ClassMetadata.

---
 lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php                  | 3 ++-
 lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php                 | 1 +
 tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
index 461038932..ed4386ac4 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
@@ -234,6 +234,7 @@ class XmlDriver extends FileDriver
 
                 if (isset($mapping['version'])) {
                     $metadata->setVersionMapping($mapping);
+                    unset($mapping['version']);
                 }
 
                 $metadata->mapField($mapping);
@@ -686,7 +687,7 @@ class XmlDriver extends FileDriver
         }
 
         if (isset($fieldMapping['version']) && $fieldMapping['version']) {
-            $mapping['version'] = $fieldMapping['version'];
+            $mapping['version'] = $this->evaluateBoolean($fieldMapping['version']);
         }
 
         if (isset($fieldMapping['column-definition'])) {
diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
index bf97f19fb..5bd58ef79 100644
--- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
+++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
@@ -300,6 +300,7 @@ class YamlDriver extends FileDriver
 
                 if (isset($mapping['version'])) {
                     $metadata->setVersionMapping($mapping);
+                    unset($mapping['version']);
                 }
 
                 $metadata->mapField($mapping);
diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
index 5d713c25c..28e6f1ede 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php
@@ -159,6 +159,8 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
     {
         $this->assertTrue($class->isVersioned);
         $this->assertEquals("version", $class->versionField);
+
+        $this->assertFalse(isset($class->fieldMappings['version']['version']));
     }
 
     /**