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.