Compare commits

...

4 Commits

Author SHA1 Message Date
Benjamin Eberlei
c2135b3821 Fix wrong version 2014-06-03 21:53:45 +02:00
Benjamin Eberlei
d932eb0b27 [DDC-3120] Fix bug with unserialize bc break in PHP 5.4.29 and PHP 5.5.13 2014-06-03 17:40:03 +02:00
Guilherme Blanco
98173032ac Fixes DDC-2984. Made DDC-742 more resilient to recurring failures. 2014-04-16 23:43:31 +02:00
Benjamin Eberlei
78c335cc80 Bump dev version to 2.3.6 2014-02-08 17:28:25 +01:00
6 changed files with 212 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "doctrine/orm",
"type": "library","version":"2.3.5",
"type": "library",
"description": "Object-Relational-Mapper for PHP",
"keywords": ["orm", "database"],
"homepage": "http://www.doctrine-project.org",

View File

@@ -827,7 +827,11 @@ class ClassMetadataInfo implements ClassMetadata
public function newInstance()
{
if ($this->_prototype === null) {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
$this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
} else {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}
}
return clone $this->_prototype;

View File

@@ -2426,15 +2426,15 @@ class UnitOfWork implements PropertyChangedListener
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName];
}
$idHash = implode(' ', $id);
} else {
$idHash = isset($class->associationMappings[$class->identifier[0]])
$id = isset($class->associationMappings[$class->identifier[0]])
? $data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']]
: $data[$class->identifier[0]];
$id = array($class->identifier[0] => $idHash);
$id = array($class->identifier[0] => $id);
}
$idHash = implode(' ', $id);
if (isset($this->identityMap[$class->rootEntityName][$idHash])) {
$entity = $this->identityMap[$class->rootEntityName][$idHash];

View File

@@ -36,7 +36,7 @@ class Version
/**
* Current Doctrine Version
*/
const VERSION = '2.3.5';
const VERSION = '2.3.6-DEV';
/**
* Compares a Doctrine version with the current one.

View File

@@ -0,0 +1,199 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\StringType;
use Doctrine\DBAL\Types\Type;
/**
* @group DDC-2984
*/
class DDC2984Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function setUp()
{
parent::setUp();
if ( ! Type::hasType('ddc2984_domain_user_id')) {
Type::addType(
'ddc2984_domain_user_id',
__NAMESPACE__ . '\DDC2984UserIdCustomDbalType'
);
}
try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2984User'),
));
} catch (\Exception $e) {
// no action needed - schema seems to be already in place
}
}
public function testIssue()
{
$user = new DDC2984User(new DDC2984DomainUserId('unique_id_within_a_vo'));
$user->applyName('Alex');
$this->_em->persist($user);
$this->_em->flush($user);
$repository = $this->_em->getRepository(__NAMESPACE__ . "\DDC2984User");
$sameUser = $repository->find(new DDC2984DomainUserId('unique_id_within_a_vo'));
//Until know, everything works as expected
$this->assertTrue($user->sameIdentityAs($sameUser));
$this->_em->clear();
//After clearing the identity map, the UnitOfWork produces the warning described in DDC-2984
$equalUser = $repository->find(new DDC2984DomainUserId('unique_id_within_a_vo'));
$this->assertNotSame($user, $equalUser);
$this->assertTrue($user->sameIdentityAs($equalUser));
}
}
/** @Entity @Table(name="users") */
class DDC2984User
{
/**
* @Id @Column(type="ddc2984_domain_user_id")
* @GeneratedValue(strategy="NONE")
*
* @var DDC2984DomainUserId
*/
private $userId;
/** @Column(type="string", length=50) */
private $name;
public function __construct(DDC2984DomainUserId $aUserId)
{
$this->userId = $aUserId;
}
/**
* @return DDC2984DomainUserId
*/
public function userId()
{
return $this->userId;
}
/**
* @return string
*/
public function name()
{
return $this->name;
}
/**
* @param string $name
*/
public function applyName($name)
{
$this->name = $name;
}
/**
* @param DDC2984User $other
* @return bool
*/
public function sameIdentityAs(DDC2984User $other)
{
return $this->userId()->sameValueAs($other->userId());
}
}
/**
* DDC2984DomainUserId ValueObject
*
* @author Alexander Miertsch <kontakt@codeliner.ws>
*/
class DDC2984DomainUserId
{
/**
* @var string
*/
private $userIdString;
/**
* @param string $aUserIdString
*/
public function __construct($aUserIdString)
{
$this->userIdString = $aUserIdString;
}
/**
* @return string
*/
public function toString()
{
return $this->userIdString;
}
/**
* @return string
*/
public function __toString()
{
return $this->toString();
}
/**
* @param DDC2984DomainUserId $other
* @return bool
*/
public function sameValueAs(DDC2984DomainUserId $other)
{
return $this->toString() === $other->toString();
}
}
/**
* Class DDC2984UserIdCustomDbalType
*
* @author Alexander Miertsch <kontakt@codeliner.ws>
*/
class DDC2984UserIdCustomDbalType extends StringType
{
public function getName()
{
return 'ddc2984_domain_user_id';
}
/**
* {@inheritDoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return ! empty($value)
? new DDC2984DomainUserId($value)
: null;
}
/**
* {@inheritDoc}
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (empty($value)) {
return null;
}
if (is_string($value)) {
return $value;
}
if ( ! $value instanceof DDC2984DomainUserId) {
throw ConversionException::conversionFailed($value, $this->getName());
}
return $value->toString();
}
}

View File

@@ -76,7 +76,7 @@ class DDC742Test extends \Doctrine\Tests\OrmFunctionalTestCase
/**
* @Entity
* @Table(name="users")
* @Table(name="ddc742_users")
*/
class DDC742User
{
@@ -109,7 +109,7 @@ class DDC742User
/**
* @Entity
* @Table(name="comments")
* @Table(name="ddc742_comments")
*/
class DDC742Comment
{