Merge pull request #1154 from Ocramius/hotfix/PHP-5.6-serialization-fix
DDC-3120 - PHP 5.6 internal classes/Serializable serialization fix
This commit is contained in:
commit
d46fa4adeb
@ -4,6 +4,7 @@ php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
|
||||
env:
|
||||
- DB=mysql
|
||||
|
@ -866,7 +866,7 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
public function newInstance()
|
||||
{
|
||||
if ($this->_prototype === null) {
|
||||
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
|
||||
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513 || PHP_VERSION_ID >= 50600) {
|
||||
$this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
|
||||
} else {
|
||||
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
|
||||
|
@ -1101,6 +1101,31 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$this->assertFalse($class->isIdentifier('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3120
|
||||
*/
|
||||
public function testCanInstantiateInternalPhpClassSubclass()
|
||||
{
|
||||
$classMetadata = new ClassMetadata(__NAMESPACE__ . '\\MyArrayObjectEntity');
|
||||
|
||||
$classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
||||
|
||||
$this->assertInstanceOf(__NAMESPACE__ . '\\MyArrayObjectEntity', $classMetadata->newInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3120
|
||||
*/
|
||||
public function testCanInstantiateInternalPhpClassSubclassFromUnserializedMetadata()
|
||||
{
|
||||
/* @var $classMetadata ClassMetadata */
|
||||
$classMetadata = unserialize(serialize(new ClassMetadata(__NAMESPACE__ . '\\MyArrayObjectEntity')));
|
||||
|
||||
$classMetadata->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
|
||||
|
||||
$this->assertInstanceOf(__NAMESPACE__ . '\\MyArrayObjectEntity', $classMetadata->newInstance());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1137,3 +1162,7 @@ class MyPrefixNamingStrategy extends \Doctrine\ORM\Mapping\DefaultNamingStrategy
|
||||
return strtolower($this->classToTableName($className)) . '_' . $propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
class MyArrayObjectEntity extends \ArrayObject
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user