1
0
mirror of synced 2025-02-20 22:23:14 +03:00

Merge branch 'hotfix/#1242-lock-uninitialized-proxies'

Close #1242
This commit is contained in:
Marco Pivetta 2015-01-13 02:37:09 +01:00
commit 1ac688644a
2 changed files with 17 additions and 0 deletions

View File

@ -2353,6 +2353,10 @@ class UnitOfWork implements PropertyChangedListener
return;
}
if ($entity instanceof Proxy && !$entity->__isInitialized__) {
$entity->__load();
}
$entityVersion = $class->reflFields[$class->versionField]->getValue($entity);
if ($entityVersion != $lockVersion) {

View File

@ -150,6 +150,19 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
}
}
public function testLockWorksWithProxy()
{
$test = new OptimisticStandard();
$test->name = 'test';
$this->_em->persist($test);
$this->_em->flush();
$this->_em->clear();
$proxy = $this->_em->getReference('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard', $test->id);
$this->_em->lock($proxy, LockMode::OPTIMISTIC, 1);
}
public function testOptimisticTimestampSetsDefaultValue()
{
$test = new OptimisticTimestamp();