Problem/Motivation

Steps to reproduce

1. Install Drupal 8 .9.x with the standard profile.
2. Enable field_encrypt, real_aes, encrypt, key
3. Create key and encryption profile (as attached)
4. Add encryption to body field of node type article.
5. Try to create a new node with a title and body text.

Expected:
Node saved with given details.

Actual:
Throws exception:

The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to Drupal\encrypt\EncryptService::encrypt() must implement interface Drupal\encrypt\EncryptionProfileInterface, null given, called in mysite/modules/contrib/field_encrypt/src/Plugin/Field/FieldType/EncryptedFieldStorageItem.php on line 68 in Drupal\encrypt\EncryptService->encrypt() (line 77 of modules/contrib/encrypt/src/EncryptService.php).
Drupal\encrypt\EncryptService->encrypt('a:1:{s:4:"body";a:1:{i:0;a:1:{s:5:"value";s:13:"test
";}}}', NULL) (Line: 68)
Drupal\field_encrypt\Plugin\Field\FieldType\EncryptedFieldStorageItem->encrypt() (Line: 89)
Drupal\field_encrypt\ProcessEntities->encryptEntity(Object) (Line: 134)
field_encrypt_entity_presave(Object)
call_user_func_array('field_encrypt_entity_presave', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array) (Line: 206)
Drupal\Core\Entity\EntityStorageBase->invokeHook('presave', Object) (Line: 843)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 500)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 700)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 454)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 837)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 395)
Drupal\Core\Entity\EntityBase->save() (Line: 294)
Drupal\node\NodeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('node_article_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
field-encrypt-1.png618.17 KBvijaycs85
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

vijaycs85 created an issue. See original summary.

vijaycs85’s picture

Turns out I haven't set the field's encryption profile. probably worth throwing a warning/error on a field storage settings page's (e.g body field) save if no profile is set at the field_encrypt level, but trying to enable encryption for the field.

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

alexpott’s picture

Status: Active » Needs review

  • alexpott committed 3df7c0b on 3.0.x
    Issue #3188278 by vijaycs85, alexpott: Exception at Drupal\field_encrypt...
alexpott’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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