How to fix Relying on entity queries to check access by default is deprecated in drupal:9.2.0

This error occurs on scanning code deprecations for Drupal 9:

Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. Call
         \Drupal\Core\Entity\Query\QueryInterface::accessCheck()

How to fix

Read the following blog post for a fix:

EntityQuery access check will be enforced in Drupal 10

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!