From da582e112588e5280263456ee1eb522692dca766 Mon Sep 17 00:00:00 2001 From: romanb Date: Sun, 14 Feb 2010 10:48:25 +0000 Subject: [PATCH] [2.0] Fixed hardcoded version field access in optimistic locking. --- lib/Doctrine/ORM/Persisters/StandardEntityPersister.php | 2 +- .../Tests/ORM/Functional/Locking/OptimisticTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php index e80af98b5..927d3c9fb 100644 --- a/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php @@ -253,7 +253,7 @@ class StandardEntityPersister $versionField = $this->_class->versionField; $versionFieldType = $this->_class->getTypeOfField($versionField); $where[$versionField] = Type::getType($versionFieldType) - ->convertToDatabaseValue($entity->version, $this->_platform); + ->convertToDatabaseValue($this->_class->reflFields[$versionField]->getValue($entity), $this->_platform); $versionFieldColumnName = $this->_class->getQuotedColumnName($versionField, $this->_platform); if ($versionFieldType == 'integer') { $set[] = $versionFieldColumnName . ' = ' . $versionFieldColumnName . ' + 1'; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index bd29ffe5a..56a0e6d47 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -94,7 +94,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($test); $this->_em->flush(); - $this->assertEquals(1, $test->version); + $this->assertEquals(1, $test->getVersion()); } /** @@ -205,7 +205,9 @@ class OptimisticStandard /** * @Version @Column(type="integer") */ - public $version; + private $version; + + function getVersion() {return $this->version;} } /**