- Issue created by @vbalsys
- Status changed to Closed: works as designed
8 months ago 3:39am 15 March 2024 - 🇺🇸United States tr Cascadia
Already fixed. 🐛 Voting Storages does not check access on entity query Fixed
Drupal 10 requires entity queries to explicitly set the access check.
This line as an example is taken from Like and dislike module:
/** @var \Drupal\votingapi\VoteResultStorageInterface $vote_result_storage */
$vote_result_storage = \Drupal::entityTypeManager()->getStorage('vote_result');
// Get like votes.
$like = $vote_result_storage->getEntityResults($entity->getEntityTypeId(), $entity->id(), 'like', 'vote_sum');
Execution of the above fails with 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 /www/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php).
Add explicit access check instruction in entity query, file src/VoteResultStorage.php, method getEntityResults():
$query = \Drupal::entityQuery('vote_result')
->accessCheck(FALSE)
->condition('entity_type', $entity_type_id)
->condition('entity_id', $entity_id)
->condition('type', $vote_type);
Closed: works as designed
Code
Already fixed. 🐛 Voting Storages does not check access on entity query Fixed