-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Dear kaihiro,
I finded a problem in listener event on the Behaviour Class. In this method doesn't considered a primary key with multiple column (unlike the trait, if it supports it):
Problem source
I've tracked the problem to this part of:
Lines 32 and 33 of file:
https://github.com/kaihiro/optimistic-lock/blob/master/src/Model/Behavior/OptimisticLockBehavior.php
/**
* versionが一致しているかをチェックします.
*
* DBの最新レコードのversionとフォームのversionが一致しない場合、OptimisticLockExceptionをスローします.
*
* @param Event $event
* @param EntityInterface $entity
* @param $options
* @param $operation
*/
public function beforeRules(Event $event, EntityInterface $entity, $options, $operation)
{
if (isset($entity->{$this->_table->primaryKey()})) {
$latestEntity = $this->_table->get($entity->{$this->_table->primaryKey()});
if (!empty($latestEntity)) {
$postVersion = $entity->get('version');
$this->postVersion = $postVersion;
$latestVersion = $latestEntity->get('version');
if ($postVersion != $latestVersion) {
$event->stopPropagation();
throw new OptimisticLockException();
}
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels