D10 compatibility: Query access check and deprecated function

Created on 5 October 2023, about 1 year ago
Updated 18 December 2023, 11 months ago

Problem/Motivation

Using the latest version of og_menu with Drupal 10 you are not able to view/edit the menu items due to two errors:

1 - <em>Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not.</em>
2 - <em>Deprecated function: Creation of dynamic property Drupal\og_menu\Form\OverviewMenuInstances::$entityTypeManager is deprecated in Drupal\og_menu\Form\OverviewMenuInstances->__construct() (line 38 of modules/contrib/og_menu/src/Form/OverviewMenuInstances.php).</em>

Steps to reproduce

Setup
- Drupal 10.1.x
- PHP 8.2.3
- Organic groups 8.x-1.0-alpha10

Steps
- Go to the OG Menu admin page /admin/structure/menu/ogmenu
- Click on Add OG Menu
- Add a label, a target bundles and save.
- You should see a success status message.
- Click on VIEW on the menu created.
- You should see the error

The website encountered an unexpected error. Please try again later.
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 core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Once this is fixed a second deprecation warning is throw
Deprecated function: Creation of dynamic property Drupal\og_menu\Form\OverviewMenuInstances::$entityTypeManager is deprecated in Drupal\og_menu\Form\OverviewMenuInstances->__construct() (line 38 of modules/contrib/og_menu/src/Form/OverviewMenuInstances.php).

Proposed resolution

- Explicitly set whether the entity query should check for access permissions or not. (/src/Form/OverviewMenuInstances.php)
- Replace the deprecated OverviewMenuInstances (/src/Form/OverviewMenuInstances.php)

Remaining tasks

- Make the necessary code changes to add the permission check.
- Resolve the deprecation warning.

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇧🇷Brazil barone Belo Horizonte

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

Comments & Activities

Production build 0.71.5 2024