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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mlncn created an issue. See original summary.

mlncn’s picture

Status: Active » Needs review

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.

joachim’s picture

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

joachim’s picture

Status: Needs review » Needs work

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.

ptmkenny made their first commit to this issue’s fork.

ptmkenny’s picture

Status: Needs work » Needs review

I've updated the MR to check for ConfigEntityInterface instead of method_exists(), and I also checked the rest of the code for calls to getThirdPartySetting. I identified two more places where we need to check before calling the method.

Please test this new MR and confirm it works with computed_field.

ptmkenny’s picture

megakeegman made their first commit to this issue’s fork.

megakeegman’s picture

Just rebasing to resolve merge conflict in #9

ptmkenny’s picture

@megakeegman Thanks for rebasing. Have you encountered this error, and does the MR fix it for your site?

megakeegman’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that I have encountered the error and that the MR does fix it

  • ptmkenny committed ca0b8c43 on 4.x authored by mlncn
    Issue #3517810 by ptmkenny, mlncn, megakeegman, joachim: Error when...
ptmkenny’s picture

Status: Reviewed & tested by the community » Fixed

Committed and will be in the next beta, thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.