1
0
mirror of synced 2025-02-02 13:31:45 +03:00

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

Close #1242
This commit is contained in:
Marco Pivetta 2015-01-13 02:36:08 +01:00
commit b11ae45a2f
2 changed files with 17 additions and 0 deletions

View File

@ -2314,6 +2314,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

@ -152,6 +152,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();