Error when computed_field module fields are present

Created on 7 April 2025, 12 days ago

Problem/Motivation

Call to undefined method Drupal\computed_field\Field\FieldStorageDefinition::getThirdPartySetting()

Error: Call to undefined method Drupal\computed_field\Field\FieldStorageDefinition::getThirdPartySetting() in Drupal\field_encrypt\ProcessEntities->getEncryptedFields() (line 215 of modules/contrib/field_encrypt/src/ProcessEntities.php).

Drupal\field_encrypt\ProcessEntities->entitySetCacheTags() (Line: 117)
Drupal\field_encrypt\Hook\FieldEncryptHooks->entityView()
call_user_func_array() (Line: 355)
Drupal\Core\Extension\ModuleHandler->{closure:Drupal\Core\Extension\ModuleHandler::invokeAll():354}() (Line: 307)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 354)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 289)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build()

Steps to reproduce

Create a computed field.

Proposed resolution

Not sure which module is to blame but it is certainly easier to fix here.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

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

Merge Requests

Comments & Activities

  • Issue created by @mlncn
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Whether other modules providing fields should always implement getThurdPartySetting or not, from Field Encrypt's point of view if that is not there the field cannot be encrypted, so we can do this check and move on. That is, this protects people using Filed Encrypt from more than only Computed Field in its current state.

  • Pipeline finished with Success
    12 days ago
    Total: 194s
    #467731
  • πŸ‡¬πŸ‡§United Kingdom joachim

    What does this module do for base fields, which don't support third party settings either?

  • πŸ‡¬πŸ‡§United Kingdom joachim

    This is an incorrect assumption:

          $is_base_field = $storage->isBaseField();
          // Check if the field is encrypted.
          if (
            ($is_base_field && $storage->getSetting('field_encrypt.encrypt')) ||
            (!$is_base_field && $storage->getThirdPartySetting('field_encrypt', 'encrypt', FALSE))
    

    A field that is not a base field is not necessarily a config field. Bundle fields can be defined in code too.

    Rather than doing

    > method_exists($storage, 'getThirdPartySetting

    in the MR, check for whether the field is a ConfigEntityInterface.

Production build 0.71.5 2024