Skip to content

Commit

Permalink
Merge pull request #172 from Invertus/lock-rebase
Browse files Browse the repository at this point in the history
 apply changes from branch SL-232/conflicting-calls.
  • Loading branch information
zuk3975 authored Jul 1, 2024
2 parents adb4c5d + ba49048 commit 5cc5042
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions controllers/front/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function postProcess()
$orderStatusService->capture($order);
}
} catch (Exception $e) {
$this->releaseLock();
// this might be executed after pending transaction is declined (e.g. with accountToAccount payment)
if (!isset($order)) {
$orderId = $this->getOrderId($cartId);
Expand Down Expand Up @@ -176,6 +177,7 @@ public function postProcess()
null,
true
);
$this->releaseLock();
die($this->module->l($e->getMessage(), self::FILENAME));
}

Expand Down
16 changes: 10 additions & 6 deletions src/Controller/AbstractSaferPayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AbstractSaferPayController extends \ModuleFrontControllerCore
/**
* @var Lock
*/
private $lock;
protected $lock;

public function __construct()
{
Expand Down Expand Up @@ -82,11 +82,6 @@ protected function applyLock($resource)
$this->lock->create($resource);

if (!$this->lock->acquire()) {
$logger = new SaferPayLog();
$logger->message = 'Lock resource conflict';
$logger->payload = $resource;
$logger->save();

return Response::respond(
$this->module->l('Resource conflict', self::FILE_NAME),
Response::HTTP_CONFLICT
Expand All @@ -110,6 +105,15 @@ protected function applyLock($resource)
);
}

protected function lockExist()
{
try {
return $this->lock->acquire();
} catch (\Exception $exception) {
return false;
}
}

protected function releaseLock()
{
try {
Expand Down

0 comments on commit 5cc5042

Please sign in to comment.