Fix to work in Drupal 9.2 and beyond

Created on 3 March 2023, over 1 year ago

Problem/Motivation

I have tried to use commerce sermepa in drupal 10 by tweaking the info file but I found the following mistake
Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in Drupal\Core\Entity\Query\Sql\Query->prepare() (line 141 of core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Steps to reproduce

I have programmed the module with the data provided by the bank. In testing mode I can send all the credentials to the bank but when I was sent back I got this message Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in Drupal\Core\Entity\Query\Sql\Query->prepare() (line 141 of core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Proposed resolution

Following this indications I found this issue https://www.drupal.org/node/3201242 . This error is being triggered here https://git.drupalcode.org/project/commerce_sermepa/-/blob/8.x-2.x/src/P...

I have tried to fork it and send a patch but drupalcode git did not allow me to. The sollution is adding
->accessCheck(true) on line 378

$payments = $payment_storage->getQuery()
->condition('payment_gateway', $this->parentEntity->id())
->condition('order_id', $order->id())
->condition('remote_id', $parameters['Ds_AuthorisationCode'])
->accessCheck(TRUE)
->execute();

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain xare

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024