Problem/Motivation

Nodes use encrypted fields (via field_encrypt). After encryption is enabled, the
original field value is no longer stored in plaintext in the database and is
replaced by an encrypted placeholder (🔒).
As a result, entity queries that rely on these fields can no longer filter results, because the stored value is not
queryable.

Steps to reproduce

  1. Create a content type with a field.
  2. Enable encryption for this field using the field_encrypt module.
  3. Save content with a value in the encrypted field.
  4. Run an entity query with a condition on the encrypted field.
  5. Observe that the query returns no results, because the stored value is replaced by an encrypted marker (🔒).

$nodeId = \Drupal::entityQuery('node')
->accessCheck(FALSE)
->condition('type','article')
->condition('field_custom_value', 'My value')
->execute();

Am I missing anything? Is it possible to somehow query the node using the encrypted fields as the query condition?

Comments

turtletrail created an issue. See original summary.

ptmkenny’s picture

This is the same root issue as #3534586: Field Encryption prevents UniqueField from working as intended. The current architecture of this module prevents the use of entity queries with encrypted fields. Perhaps there is a way to make this more clear on the project page.