DDC-178 - Fixed problems occuring from merging upstream, re-ran API and tests, finalizing lock-support for merge with upstream
This commit is contained in:
parent
64b57bbcfb
commit
8a67621b6a
3 changed files with 10 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Reference in a new issue