mirror of
https://github.com/doctrine/orm.git
synced 2026-04-27 00:18:04 +02:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bebacf79d8 | |||
| d46fa4adeb | |||
| 64061bafaf | |||
| a69584a841 | |||
| 8fc1c34b29 | |||
| 0d683c1897 | |||
| 60b75fefed | |||
| 0a7e0617cc | |||
| 072e1eee7b | |||
| c0d3cdbdfb | |||
| a50ae2c898 | |||
| dbbe7a4be5 | |||
| 406e177062 | |||
| fc19c3b53d | |||
| 5c5abb6771 | |||
| 42226dadd1 | |||
| 84f8ef5ca4 |
@@ -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));
|
||||
|
||||
@@ -894,8 +894,8 @@ class QueryBuilder
|
||||
*/
|
||||
public function andWhere($where)
|
||||
{
|
||||
$where = $this->getDQLPart('where');
|
||||
$args = func_get_args();
|
||||
$where = $this->getDQLPart('where');
|
||||
|
||||
if ($where instanceof Expr\Andx) {
|
||||
$where->addMultiple($args);
|
||||
@@ -927,8 +927,8 @@ class QueryBuilder
|
||||
*/
|
||||
public function orWhere($where)
|
||||
{
|
||||
$where = $this->getDqlPart('where');
|
||||
$args = func_get_args();
|
||||
$where = $this->getDqlPart('where');
|
||||
|
||||
if ($where instanceof Expr\Orx) {
|
||||
$where->addMultiple($args);
|
||||
@@ -1007,8 +1007,8 @@ class QueryBuilder
|
||||
*/
|
||||
public function andHaving($having)
|
||||
{
|
||||
$having = $this->getDqlPart('having');
|
||||
$args = func_get_args();
|
||||
$having = $this->getDqlPart('having');
|
||||
|
||||
if ($having instanceof Expr\Andx) {
|
||||
$having->addMultiple($args);
|
||||
@@ -1030,8 +1030,8 @@ class QueryBuilder
|
||||
*/
|
||||
public function orHaving($having)
|
||||
{
|
||||
$having = $this->getDqlPart('having');
|
||||
$args = func_get_args();
|
||||
$having = $this->getDqlPart('having');
|
||||
|
||||
if ($having instanceof Expr\Orx) {
|
||||
$having->addMultiple($args);
|
||||
|
||||
@@ -925,12 +925,13 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
|
||||
if ($changeSet) {
|
||||
$this->entityChangeSets[$oid] = (isset($this->entityChangeSets[$oid]))
|
||||
? array_merge($this->entityChangeSets[$oid], $changeSet)
|
||||
: $changeSet;
|
||||
|
||||
if (isset($this->entityChangeSets[$oid])) {
|
||||
$this->entityChangeSets[$oid] = array_merge($this->entityChangeSets[$oid], $changeSet);
|
||||
} else if ( ! isset($this->entityInsertions[$oid])) {
|
||||
$this->entityChangeSets[$oid] = $changeSet;
|
||||
$this->entityUpdates[$oid] = $entity;
|
||||
}
|
||||
$this->originalEntityData[$oid] = $actualData;
|
||||
$this->entityUpdates[$oid] = $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2499,7 +2500,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
|
||||
$id = array($class->identifier[0] => $id);
|
||||
}
|
||||
|
||||
|
||||
$idHash = implode(' ', $id);
|
||||
|
||||
if (isset($this->identityMap[$class->rootEntityName][$idHash])) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.4.3';
|
||||
const VERSION = '2.4.6';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\Models\CMS\CmsUser;
|
||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||
use Doctrine\ORM\Events;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* FlushEventTest
|
||||
*
|
||||
* @author robo
|
||||
*/
|
||||
class DDC3160Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp() {
|
||||
$this->useModelSet('cms');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-3160
|
||||
*/
|
||||
public function testNoUpdateOnInsert()
|
||||
{
|
||||
$listener = new DDC3160OnFlushListener();
|
||||
$this->_em->getEventManager()->addEventListener(Events::onFlush, $listener);
|
||||
|
||||
$user = new CmsUser;
|
||||
$user->username = 'romanb';
|
||||
$user->name = 'Roman';
|
||||
$user->status = 'Dev';
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->flush();
|
||||
|
||||
$this->_em->refresh($user);
|
||||
|
||||
$this->assertEquals('romanc', $user->username);
|
||||
$this->assertEquals(1, $listener->inserts);
|
||||
$this->assertEquals(0, $listener->updates);
|
||||
}
|
||||
}
|
||||
|
||||
class DDC3160OnFlushListener
|
||||
{
|
||||
public $inserts = 0;
|
||||
public $updates = 0;
|
||||
|
||||
public function onFlush(OnFlushEventArgs $args)
|
||||
{
|
||||
$em = $args->getEntityManager();
|
||||
$uow = $em->getUnitOfWork();
|
||||
|
||||
foreach ($uow->getScheduledEntityInsertions() as $entity) {
|
||||
$this->inserts++;
|
||||
if ($entity instanceof CmsUser) {
|
||||
$entity->username = 'romanc';
|
||||
$cm = $em->getClassMetadata(get_class($entity));
|
||||
$uow->recomputeSingleEntityChangeSet($cm, $entity);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($uow->getScheduledEntityUpdates() as $entity) {
|
||||
$this->updates++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user