Using the disable eval setting crashes the module, but the module's use of eval() is redundant anyway

Created on 22 July 2022, almost 2 years ago
Updated 9 February 2023, over 1 year ago

Problem/Motivation

If diseval is enabled, or it is disabled using the settings: $settings['field_encrypt.use_eval_for_entity_hooks'] = FALSE;, when saving an entity, it produces a fatal error:
An invalid implementation field_encrypt_{entity_type}_insert was added by hook_module_implements_alter

Steps to reproduce

Configure as normal by adding a key, encyrption profile, and a field to be encrypted.
Add $settings['field_encrypt.use_eval_for_entity_hooks'] = FALSE; to the settings.php file
Attempt to save the entity type with the encrypted field.
Observe the error.

Proposed resolution

1. Don't add the hook when eval is not permitted. the field_encrypt_entity_update & field_encrypt_entity_insert already do the work necessary. Why is there even a need to use the eval function generator?
2. release a new version.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pookmish

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    just duplicated using the less specific entity hooks.

    This is not correct. The hook are all fired at different times. The reason we have to eval these hooks into existence is because there is no way of decrypting the entity prior to these hooks being fired. This can cause all sorts of problems. The hooks that you think are missing are not there because for these hooks we can decrypt the entity first - so we don't need to eval them into existence.

    This is all documented in the module. See

    /**
     * Implements hook_module_implements_alter().
     *
     * The Field Encrypt module decrypts and encrypts entity data by implementing
     * regular entity hooks. The order in which the hooks are fired determines
     * whether the entity data is encrypted or decrypted. It is important for that
     * for other implementations of these hooks that data is encrypted and decrypted
     * at the right time.
     * - field_encrypt_entity_storage_load() needs to be the first implementation
     *   of hook_entity_storage_load() so other implementations can use decrypted
     *   data.
     * - field_encrypt_entity_presave() needs to be the last implementation of
     *   hook_entity_presave() so other implementations can use decrypted
     *   data.
     * - field_encrypt_entity_insert() and field_encrypt_entity_update() can not
     *   be triggered in the correct location as hook_ENTITY_TYPE_insert() and
     *   hook_ENTITY_TYPE_update() are triggered first. Field encrypt tries to get
     *   around this by dynamically declaring hook_ENTITY_TYPE_insert() and
     *   hook_ENTITY_TYPE_update() implementations.
     *
     * @see field_encrypt_entity_storage_load()
     * @see field_encrypt_entity_presave()
     * @see field_encrypt_entity_insert()
     * @see field_encrypt_entity_update()
     * @see _field_encrypt_define_entity_hooks()
     * @see \Drupal\Core\Entity\EntityStorageBase::invokeHook()
     */
    function field_encrypt_module_implements_alter(&$implementations, $hook) {
    
Production build 0.69.0 2024