Fix error: Entity queries must explicitly set whether the query should be access checked or not.

Created on 16 February 2024, 7 months ago
Updated 6 March 2024, 7 months ago

Problem/Motivation

This module does not currently add accessCheck() to the log query it uses in AssetTerminationItemList.php.

In farmOS v3 (Drupal 10) this causes an error:

Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck().

Related change record: https://www.drupal.org/node/3201242 β†’

Steps to reproduce

  1. Install in farmOS v3 instance.
  2. Go to an API asset endpoint (eg: /api/asset/plant).
  3. Observe the error.

Proposed resolution

Add $query->accessCheck(TRUE); between lines 31 and 32 here:

https://git.drupalcode.org/project/farm_asset_termination/-/blob/af9f6ea...

We may also want to consider setting this by default in farmOS core's LogQueryFactory::getQuery() method (with a default of accessCheck(TRUE), but an option to override). But that would be a feature request for farmOS core, whereas this is a bug report currently in farm_asset_termination, so I think we should fix here and then follow up in core if that makes sense.

Remaining tasks

Create a MR for review.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States m.stenta

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024