Per arknoll:

I just installed these three sets of dependencies and translations aren't being displayed appropriately. Here is what I did.

Enabled all modules (workbench moderation, key, encrypt, field encrypt, real_aes, content translations, translate)
Set up workflow states (draft, review, publish, archive) and transitions between each state
Added workflow to basic page content type
Added a test key and encryption profile.
Enabled French translation on the site
Encrypted the body field on the basic page
Created a basic page node and transitioned to review
Created a french translation of the node and saved as draft
Expected result, viewing the french draft would display the french content

Actual result, viewing the french draft shows the english content.

This works as expected when workbench moderation is not being used.

Comments

nerdstein created an issue. See original summary.

dawehner’s picture

As talked with @nerdstein this is probably "just" the problem that field encrypt doesn't support translations at all.

dawehner’s picture

Reporting some progress ...

It turns out we store a different value for the translated value in the DB:

select id, entity_id, entity_revision_id, langcode, encrypted_value__value  from encrypted_field_data;
+----+-----------+--------------------+----------+------------------------------------------------------+
| id | entity_id | entity_revision_id | langcode | encrypted_value__value                               |
+----+-----------+--------------------+----------+------------------------------------------------------+
|  2 |         2 |                  5 | en       | MTIzNDU2Nzg5MDEyMzQ1NjxjPmdyZmcgb2JxbDwvYz4NCg==     |
|  3 |         2 |                  6 | en       | MTIzNDU2Nzg5MDEyMzQ1NjxjPmdyZmcgb2JxbDwvYz4NCg==     |
|  4 |         2 |                  6 | de       | MTIzNDU2Nzg5MDEyMzQ1NjxjPmdyZmcgb2JxbCBRUjwvYz4NCg== |
+----+-----------+--------------------+----------+------------------------------------------------------+

Given that I guess this is a rendering problem.

dawehner’s picture

StatusFileSize
new3.56 KB

So @nerdstein and myself discussed that a bit.

There are two possibilities to implement proper translation and revision support:

  1. We store one encrypted_value-entity per translation and revision of the source entity. See the first patch. This fixed the issue described well in the issue summary for me.
  2. We store one entity per source entity and encrypted_value-entity (entity_type_id, entity_id, field_name) and sync translations and revisions with the source entity. This is basically how the module was designed to work, but it never worked really.
dawehner’s picture

Status: Active » Needs review

I'm not 100% convinced that going with the way 1) is the only possibility we have, but it certainly simplifies things a lot.

dawehner’s picture

StatusFileSize
new3.56 KB

Here is a try to actually add some test coverage just for that case, turns out, either the test or the actual implementation is still wrong.

dawehner’s picture

StatusFileSize
new12.66 KB

This time also with the test.

Currently I'm a bit buffled about

    $languages = $entity->getTranslationLanguages();
    foreach ($languages as $language) {

For the testcase the languages are 'en', and 'fr', but the entity internally stores in 'fr' and 'x-default', which is maybe a problem here as well.

dawehner’s picture

StatusFileSize
new5.64 KB
new2.35 KB

Its tricky. I tried to write the tests properly on the storage layer, but I could not yet reproduce the issue on that layer.

While working on the test I realized a couple of issues though:

* We use a hook which is cached, see #2743073: hook_entity_storage_load() is cached
* We potentially re-encrypt '[ENCRYPTED_VALUE]'. I haven't figured out when this happens exactly, but I've seen the behaviour while writing the tests
* The tests require a $storage->reset() call for some reason

nerdstein’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed this patch and it seems to be working as intended for this module. I can't rule out any issues with WBM though but the test proves that Field Encrypt seems to be working and respecting both revisions and translations properly now.

arknoll’s picture

I have also reviewed and it appears to be working for me.

Thank you!

nerdstein’s picture

dawehner, the patch for the code is great, but the test patch is failing. I tried to rebuild the test patch in #8 from the patch in #6 and there are gaps. Can you take a look?

nerdstein’s picture

From FieldEncryptStorageTest class: missing "assertRawEncrypedFieldDataEntry" function and "assertRawEncryptedValues" has a missing third parameter I can't find ;)

  • nerdstein committed 6abc79f on 8.x-2.x authored by dawehner
    Issue #2735927 by dawehner: Workbench moderation + field encrypt +...
nerdstein’s picture

Status: Reviewed & tested by the community » Needs work
ptmkenny’s picture

Status: Needs work » Closed (outdated)

This was fixed in #13, so I'm closing the issue now. If you have a similar problem, please open a new issue.