Skip to content

User entity reference fields doesn't work properly #289

@jansete

Description

@jansete

If you try something like

    Given users:
      | name           | 
      | behat_user | 
    Given "article" content:
      | title               | status   | field_watchers |
      | My article    |  1           | behat_user       |

The following query located in \Drupal\Driver\Fields\Drupal8\EntityReferenceHandler::expand returns two results, first user 0 (anonymous user) then your user, so in the end of the method, it always return anonymous user.

$query = \Drupal::entityQuery($entity_type_id);
$or = $query->orConditionGroup();
$or->condition($id_key, $value)
  ->condition($label_key, $value);
$query->condition($or);
$query->accessCheck(FALSE);

The problem is because the uid column in users_field_data table is integer, and database engine cast 'behat_user' into integer setting 0 because the original value is a string and not a number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions