For D10 ->accessCheck(TRUE) missing in NextPreviousBlock.php

Created on 18 April 2023, over 1 year ago
Updated 23 April 2023, over 1 year ago

Hi there.

Just got this:

Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not.

with the 9.0.2 Version on Drupal 10.0.7.

After having a look at the code I found that the required ->accessCheck(TRUE) is missing in NextPreviousBlock.php line around line 240.
Adding it fixed the error.

// Lookup 1 node younger (or older) than the current node.
    $query = $this->entityTypeManager->getStorage('node');
    $query_result = $query->getQuery();
    $next = $query_result->condition('nid', $current_nid, $comparison_opperator)
      ->condition('type', $this->configuration['content_type'])
      ->condition('status', 1)
      ->condition('langcode', $current_langcode)
      ->sort('nid', $sort)
      ->range(0, 1)
      ->accessCheck(TRUE)
      ->execute();

Also see: https://www.drupal.org/node/3201242

Best

Jan

🐛 Bug report
Status

Fixed

Version

9.0

Component

Code

Created by

🇩🇪Germany netzkombuese

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

Comments & Activities

Production build 0.71.5 2024