Problem/Motivation

Getting following PHP Fatal Error with Drupal 10.

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 /var/www/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Steps to reproduce

  1. Install Drupal 10.
  2. Install and configure recently_read module.
  3. Create and view a node.

Proposed resolution

Access checking must be explicitly specified on content entity queries

CommentFileSizeAuthor
#19 3362224-4.patch1.25 KBloicfer
#12 3362224-3.patch571 bytesjp_sc
#2 3362224-2.patch688 bytessamitk
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

samit.310@gmail.com created an issue. See original summary.

samitk’s picture

Assigned: samitk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new688 bytes

Issue fixed.

keshav.k made their first commit to this issue’s fork.

keshavv’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and tested patch.
It is working good. Created MR for easy merge

  • zterry95 committed df9c2539 on 8.x-1.x authored by keshav.k
    Issue #3362224: PHP Fatal Error | Drupal\Core\Entity\Query\...
deaom’s picture

Status: Reviewed & tested by the community » Fixed

The MR seems to be merged, but the status was not changed to fixed, so just updating the status.

deaom’s picture

Status: Fixed » Reviewed & tested by the community

Changing the status back to RTBC, so maintainers can give credit.

lysenko’s picture

+1 RTBC

jp_sc changed the visibility of the branch 3362224-php-fatal-error to hidden.

jp_sc changed the visibility of the branch 3362224-php-fatal-error to active.

jp_sc’s picture

StatusFileSize
new571 bytes

Same issue seems to appear in recently_read_cron() in recently_read.module.

j_edery’s picture

I have found another Drupal 10 compatibility issue with the code which results in a PHP error during testing.

j_edery’s picture

I have issued another merge request to resolve the issue. I have tested and can confirm this resolves the PHP fatal error when running cron.

j_edery’s picture

I have added my fix to a new issue and created a merge request here: https://www.drupal.org/project/recently_read/issues/3407065#comment-1535...

Frontmobe made their first commit to this issue’s fork.

loicfer’s picture

StatusFileSize
new1.25 KB

Hello,

When using this module on Drupal 10, it throws a QueryException because entity queries in both recently_read.module and RecentlyReadService.php do not explicitly define whether to check for access permissions.

This patch adds ->accessCheck(TRUE) to all affected entity queries:

  • recently_read_cron() in recently_read.module
  • getRecords() method in RecentlyReadService.php

This is required since Drupal 9.4+, and mandatory in Drupal 10.
This patch takes up the old patch and adds the fix to it for the getRecords() method

✅ The patch is tested and works with Composer patching.

Thanks for maintaining the module!

Best regards,

Anonymous’s picture

jernejmramor made their first commit to this issue’s fork.

Anonymous’s picture

Status: Reviewed & tested by the community » Fixed

Closing this as this was tested, merged and resolved. Credited everyone that spent time on this. This will be included in the next release of this module.

Anonymous’s picture

Version: 8.x-1.x-dev » 8.x-1.4
Status: Fixed » Closed (fixed)

Closing this as it was released in the 1.4 version of this module.