Skip to content

Commit e1c691b

Browse files
fathershawnbojanz
authored andcommitted
Issue #2900938 by FatherShawn: PaymentAccessControlHandler fails if the Order does not exist
1 parent 9f8fa47 commit e1c691b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

modules/payment/src/PaymentAccessControlHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class PaymentAccessControlHandler extends EntityAccessControlHandler {
1919
*/
2020
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
2121
/** @var \Drupal\commerce_payment\Entity\PaymentInterface $entity */
22+
$order = $entity->getOrder();
2223
$access = AccessResult::allowedIfHasPermission($account, $this->entityType->getAdminPermission())
23-
->andIf(AccessResult::allowedIf($entity->getOrder()->access('view', $account, TRUE)))
24+
->andIf(AccessResult::allowedIf($order && $order->access('view', $account, TRUE)))
2425
->addCacheableDependency($entity);
2526
if ($operation == 'delete') {
2627
// @todo Add a payment gateway method for this check,

0 commit comments

Comments
 (0)