From ba8cb27f1032b93843aecda71368d8e0dfd5ff3c Mon Sep 17 00:00:00 2001 From: Eirik Stanghelle Morland Date: Sun, 3 Nov 2024 15:55:48 +0100 Subject: [PATCH] Avoid referencing UID 0 not on purpose --- src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php b/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php index 5ea3217..4b1400e 100644 --- a/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php +++ b/src/Drupal/Driver/Fields/Drupal8/EntityReferenceHandler.php @@ -39,7 +39,10 @@ public function expand($values) { foreach ((array) $values as $value) { $query = \Drupal::entityQuery($entity_type_id); $or = $query->orConditionGroup(); - $or->condition($id_key, $value) + $id_group = $query->andConditionGroup() + ->condition($id_key, $value) + ->condition($id_key, 0, '<>'); + $or->condition($id_group) ->condition($label_key, $value); $query->condition($or); $query->accessCheck(FALSE);