Commit 8a67621b authored by Benjamin Eberlei's avatar Benjamin Eberlei

DDC-178 - Fixed problems occuring from merging upstream, re-ran API and tests,...

DDC-178 - Fixed problems occuring from merging upstream, re-ran API and tests, finalizing lock-support for merge with upstream
parent 64b57bbc
......@@ -24,6 +24,7 @@ namespace Doctrine\ORM;
* that uses optimistic locking through a version field fails.
*
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @since 2.0
*/
class OptimisticLockException extends ORMException
......@@ -50,13 +51,13 @@ class OptimisticLockException extends ORMException
return new self("The optimistic lock on an entity failed.", $entity);
}
public static function lockFailedVersionMissmatch($expectedLockVersion, $actualLockVersion)
public static function lockFailedVersionMissmatch($entity, $expectedLockVersion, $actualLockVersion)
{
return new self("The optimistic lock failed, version " . $expectedLockVersion . " was expected, but is actually ".$actualLockVersion);
return new self("The optimistic lock failed, version " . $expectedLockVersion . " was expected, but is actually ".$actualLockVersion, $entity);
}
public static function notVersioned($className)
public static function notVersioned($entityName)
{
return new self("Cannot obtain optimistic lock on unversioned entity ".$className);
return new self("Cannot obtain optimistic lock on unversioned entity " . $entityName, null);
}
}
\ No newline at end of file
......@@ -1654,7 +1654,7 @@ class UnitOfWork implements PropertyChangedListener
if ($lockVersion != null) {
$entityVersion = $class->reflFields[$class->versionField]->getValue($entity);
if ($entityVersion != $lockVersion) {
throw OptimisticLockException::lockFailedVersionMissmatch($lockVersion, $entityVersion);
throw OptimisticLockException::lockFailedVersionMissmatch($entity, $lockVersion, $entityVersion);
}
}
} else if ($lockMode == LockMode::PESSIMISTIC_READ || $lockMode == LockMode::PESSIMISTIC_WRITE) {
......
......@@ -140,7 +140,7 @@ class GearmanLockTest extends \Doctrine\Tests\OrmFunctionalTestCase
protected function asyncFindWithLock($entityName, $entityId, $lockMode)
{
$this->startGearmanJob('findWithLock', array(
$this->startJob('findWithLock', array(
'entityName' => $entityName,
'entityId' => $entityId,
'lockMode' => $lockMode,
......@@ -149,7 +149,7 @@ class GearmanLockTest extends \Doctrine\Tests\OrmFunctionalTestCase
protected function asyncDqlWithLock($dql, $params, $lockMode)
{
$this->startGearmanJob('dqlWithLock', array(
$this->startJob('dqlWithLock', array(
'dql' => $dql,
'dqlParams' => $params,
'lockMode' => $lockMode,
......@@ -158,14 +158,14 @@ class GearmanLockTest extends \Doctrine\Tests\OrmFunctionalTestCase
protected function asyncLock($entityName, $entityId, $lockMode)
{
$this->startGearmanJob('lock', array(
$this->startJob('lock', array(
'entityName' => $entityName,
'entityId' => $entityId,
'lockMode' => $lockMode,
));
}
protected function startGearmanJob($fn, $fixture)
protected function startJob($fn, $fixture)
{
$this->gearman->addTask($fn, serialize(array(
'conn' => $this->_em->getConnection()->getParams(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment