Problem/Motivation
On Drupal version 10.2.x+ encrypted decimal field values are no longer being saved.
This bug stems from a new decimal primitive data type that was added in 10.2.0 (https://www.drupal.org/node/3376447). The decimal data type is not handled by the switch statement in \Drupal\field_encrypt\ProcessEntities::getUnencryptedPlaceholderValue , therefore this method returns NULL. This results in the field value getting set to NULL.
The value is still successfully encrypted and stored in encrypted_field_storage, however, when the entity is decrypted the stored value is not applied. This is because $field->getValue() returns an empty array so the field properties are not updated in \Drupal\field_encrypt\ProcessEntities::setEncryptedFieldValues.
Steps to reproduce
- Set up a Content Type with a encrypted Number (decimal) field.
- Create a node for that Content Type setting the decimal field value.
- The field value is not visible when viewing or editing the new node.
Proposed resolution
Update \Drupal\field_encrypt\ProcessEntities::getUnencryptedPlaceholderValue and add decimal data type to the switch statement.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3488771-encrypted-decimal-field-3.patch | 16.21 KB | tame4tex |
Issue fork field_encrypt-3488771
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
Comment #3
tame4tex commentedI have created MR !73 to add both testing and a fix for this bug.
Modifying
ProcessEntitiesTestwas not enough to test for this bug as it seems this unit test is allowing unexpected results to slip through. I have added a separate issue for this #3488808: ProcessEntitiesTest is allowing unexpected results to slip through.I therefore added Functional testing to ensure there is adequate coverage for this bug.
Comment #4
tame4tex commentedComment #5
ptmkenny commentedThis was originally reported by pp.panatom in #3465540: Drupal 10.2 - field values on decimal fields getting lost, which I mistakenly closed-- I'm sorry for incorrectly closing that. However, I'm leaving that issue closed in favor of this one because this one has tests.
Comment #6
alexpottThis looks good.
Comment #8
alexpott