Skip to content

Commit afe1fe2

Browse files
authored
fix: Sequential persist with OptimisticLock (#41)
use state transaction data instead of node data
1 parent 0c8d84f commit afe1fe2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Listener/OptimisticLock.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ public function __invoke(OnDelete|OnUpdate $event): void
8080

8181
private function lock(Node $node, State $state, ScopeCarrierInterface $command): WrappedStoreCommand
8282
{
83-
$nodeValue = $node->getData()[$this->field] ?? null;
84-
if ($nodeValue === null) {
85-
throw new OptimisticLockException(\sprintf('The `%s` field is not set.', $this->field));
86-
}
83+
$nodeValue = $state->getTransactionData()[$this->field] ?? throw new OptimisticLockException(
84+
\sprintf('The field %s.%s is not set.', $node->getRole(), $this->field),
85+
);
8786

8887
// Process known rule
8988
if ($this->isKnownRule) {

0 commit comments

Comments
 (0)