Commit 88e3ff9d authored by catch's avatar catch
Browse files

Issue #3202125 by jonathanshaw, Berdir, catch, longwave: EntityQuery...

Issue #3202125 by jonathanshaw, Berdir, catch, longwave: EntityQuery accessCheck: unique value validation should not be access sensitive

(cherry picked from commit 96aa5ca5)
parent 1ce06ac8
......@@ -25,6 +25,9 @@ public function validate($items, Constraint $constraint) {
$query = \Drupal::entityQuery($entity_type_id);
// @todo Don't check access. http://www.drupal.org/node/3171047
$query->accessCheck(TRUE);
$entity_id = $entity->id();
// Using isset() instead of !empty() as 0 and '0' are valid ID values for
// entity types using string IDs.
......
......@@ -128,6 +128,7 @@ protected function exists($value) {
->entityTypeManager
->getStorage($this->configuration['entity_type'])
->getQuery()
->accessCheck(FALSE)
->condition($this->configuration['field'], $value);
if (!empty($this->configuration['migrated'])) {
// Check if each entity is in the ID map.
......
......@@ -43,6 +43,9 @@ protected function setUp(): void {
$this->entityQuery = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryInterface')
->disableOriginalConstructor()
->getMock();
$this->entityQuery->expects($this->any())
->method('accessCheck')
->will($this->returnSelf());
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$storage = $this->createMock(EntityStorageInterface::class);
......@@ -189,6 +192,7 @@ public function testMakeUniqueEntityFieldMigrated() {
foreach (['forums', 'test_vocab', 'test_vocab1'] as $id) {
$query = $this->prophesize(QueryInterface::class);
$query->willBeConstructedWith([]);
$query->accessCheck()->willReturn($query);
$query->execute()->willReturn($id === 'test_vocab1' ? [] : [$id]);
$map[] = ['test_field', $id, NULL, NULL, $query->reveal()];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment