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
- Create a content type with a field.
- Enable encryption for this field using the field_encrypt module.
- Save content with a value in the encrypted field.
- Run an entity query with a condition on the encrypted field.
- 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
Comment #2
ptmkenny commentedThis 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.