mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Ensured visits tracking is run transactionally together with the event dispatched afterwards
This commit is contained in:
@@ -65,9 +65,11 @@ class VisitsTracker implements VisitsTrackerInterface
|
||||
|
||||
private function trackVisit(Visit $visit, Visitor $visitor): void
|
||||
{
|
||||
$this->em->persist($visit);
|
||||
$this->em->flush();
|
||||
$this->em->transactional(function () use ($visit, $visitor): void {
|
||||
$this->em->persist($visit);
|
||||
$this->em->flush();
|
||||
|
||||
$this->eventDispatcher->dispatch(new UrlVisited($visit->getId(), $visitor->getRemoteAddress()));
|
||||
$this->eventDispatcher->dispatch(new UrlVisited($visit->getId(), $visitor->getRemoteAddress()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user