Merge branch 'hotfix/#1242-lock-uninitialized-proxies' into 2.4
Close #1242
This commit is contained in:
commit
b11ae45a2f
@ -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) {
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user