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
- Install Drupal 10.
- Install and configure recently_read module.
- Create and view a node.
Proposed resolution
Access checking must be explicitly specified on content entity queries
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3362224-4.patch | 1.25 KB | loicfer |
| #12 | 3362224-3.patch | 571 bytes | jp_sc |
| #2 | 3362224-2.patch | 688 bytes | samitk |
Issue fork recently_read-3362224
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
Comment #2
samitk commentedIssue fixed.
Comment #5
keshavv commentedReviewed and tested patch.
It is working good. Created MR for easy merge
Comment #7
deaom commentedThe MR seems to be merged, but the status was not changed to fixed, so just updating the status.
Comment #8
deaom commentedChanging the status back to RTBC, so maintainers can give credit.
Comment #9
lysenko+1 RTBC
Comment #12
jp_sc commentedSame issue seems to appear in recently_read_cron() in recently_read.module.
Comment #13
j_edery commentedI have found another Drupal 10 compatibility issue with the code which results in a PHP error during testing.
Comment #15
j_edery commentedI have issued another merge request to resolve the issue. I have tested and can confirm this resolves the PHP fatal error when running cron.
Comment #16
j_edery commentedI 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...
Comment #19
loicfer commentedHello,
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:
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,
Comment #20
Anonymous (not verified) commentedjernejmramor made their first commit to this issue’s fork.
Comment #23
Anonymous (not verified) commentedClosing 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.
Comment #24
Anonymous (not verified) commentedClosing this as it was released in the 1.4 version of this module.