diff --git a/Observer/LockUnlockOrder.php b/Observer/LockUnlockOrder.php
index e1bf8780477..b3d513edce4 100644
--- a/Observer/LockUnlockOrder.php
+++ b/Observer/LockUnlockOrder.php
@@ -1,4 +1,8 @@
lockService = $lockService;
- $this->config = $config;
}
public function execute(Observer $observer)
@@ -41,7 +42,7 @@ public function execute(Observer $observer)
throw new LocalizedException(__('Unable to get lock for %1', $key));
}
- $this->lockService->lock($key);
+ $this->lockService->lock($key, -1, $this->reason);
}
if (strpos($name, 'save_after') !== false) {
@@ -54,6 +55,13 @@ private function getOrder(string $name, Observer $observer): OrderInterface
/** @var ShipmentInterface $shipment */
$shipment = $observer->getEvent()->getData('shipment');
- return $shipment->getOrder();
+ if ($shipment) {
+ $this->reason = 'shipment';
+ return $shipment->getOrder();
+ }
+
+ $this->reason = 'shipment tracking';
+ $track = $observer->getEvent()->getData('track');
+ return $track->getShipment()->getOrder();
}
}
diff --git a/Service/LockService.php b/Service/LockService.php
index fcd496115d1..1c17b891c56 100644
--- a/Service/LockService.php
+++ b/Service/LockService.php
@@ -61,16 +61,18 @@ public function __construct(
*
* @param string $name lock name
* @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
+ * @param ?string $reason Reason for locking, will be logged only
* @return bool
*/
- public function lock(string $name, int $timeout = -1): bool
+ public function lock(string $name, int $timeout = -1, ?string $reason = null): bool
{
// Make sure we only lock once per request.
if ($this->alreadyLocked) {
return true;
}
- $this->config->addToLog('info', 'Locking: ' . $name);
+ $message = 'Locking: ' . $name . ($reason ? ' - Reaseon: ' . $reason : '');
+ $this->config->addToLog('info', $message);
if ($this->isLockManagerAvailable()) {
return $this->alreadyLocked = $this->lockManager->lock($name, $timeout);
}
diff --git a/etc/events.xml b/etc/events.xml
index de771b9207c..c385ca1e918 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -19,8 +19,13 @@
+
+
+
+
+