Missing access check on entityQuery

Created on 10 July 2023, over 1 year ago
Updated 16 July 2023, over 1 year ago

Problem/Motivation

We configured SCN to send an email when a new comment has been posted.
After a migration to Drupal 10.0.10, using PHP 8.1.20, and SCN 2.0.2, we were having the following error :
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(). dans Drupal\Core\Entity\Query\Sql\Query->prepare() (ligne 141 de /opt/bitnami/drupal/core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

I identified that SCN was using an EntityQuery to get all the user to be able to filter on the configured roles and get the email addresses to send a mail to.

Since Drupal 10 (deprecated in v9.2), it is required to explicitly call the access check function.

Proposed resolution

I added the call to the function accessCheck in scn_entity_insert function of scn.module file.

Regards,
Romain

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇫🇷France rveillard

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

Comments & Activities

Production build 0.71.5 2024