Skip to content

Commit

Permalink
Merge branch 'hotfix/#1381-wakeup-reflection-with-embeddable-and-stat…
Browse files Browse the repository at this point in the history
…icreflection-serialization-fix-2.5' into 2.5

Close #1381
  • Loading branch information
Ocramius committed Jul 15, 2015
2 parents 12d1787 + 9097014 commit f9bbd95
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Expand Up @@ -945,7 +945,7 @@ public function wakeupReflection($reflService)
}

foreach ($this->fieldMappings as $field => $mapping) {
if (isset($mapping['declaredField'])) {
if (isset($mapping['declaredField']) && isset($parentReflFields[$mapping['declaredField']])) {
$this->reflFields[$field] = new ReflectionEmbeddedProperty(
$parentReflFields[$mapping['declaredField']],
$reflService->getAccessibleProperty($mapping['originalClass'], $mapping['originalField']),
Expand Down
25 changes: 25 additions & 0 deletions tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\Tests\ORM\Mapping;

use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
use Doctrine\Common\Persistence\Mapping\StaticReflectionService;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
Expand Down Expand Up @@ -1125,6 +1126,30 @@ public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetada

$this->assertInstanceOf(__NAMESPACE__ . '\\MyArrayObjectEntity', $classMetadata->newInstance());
}

public function testWakeupReflectionWithEmbeddableAndStaticReflectionService()
{
$classMetadata = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1');

$classMetadata->mapEmbedded(array(
'fieldName' => 'test',
'class' => 'Doctrine\Tests\ORM\Mapping\TestEntity1',
'columnPrefix' => false,
));

$field = array(
'fieldName' => 'test.embeddedProperty',
'type' => 'string',
'originalClass' => 'Doctrine\Tests\ORM\Mapping\TestEntity1',
'declaredField' => 'test',
'originalField' => 'embeddedProperty'
);

$classMetadata->mapField($field);
$classMetadata->wakeupReflection(new StaticReflectionService());

$this->assertEquals(array('test' => null, 'test.embeddedProperty' => null), $classMetadata->getReflectionProperties());
}
}

/**
Expand Down

0 comments on commit f9bbd95

Please sign in to comment.