13
December
Problem:
I am using entityQuery to get Node by using following method
$query = \Drupal::entityQuery('node'); $query->condition('type', 'tours'); // Limit the type of node to check $query->condition('status',1); $nids = $query->execute();
but its return following error
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).
Solution:
I added one more line ( $query->accessCheck(); ) in my query, so now issue resolved and query working fine.
$query = \Drupal::entityQuery('node'); $query->condition('type', 'tours'); // Limit the type of node to check $query->condition('status',1); $query->accessCheck(); $nids = $query->execute();
© 2023.ZedAngle. All Rights Reserved.