We found this issue recently.

When we build a multi-language website. There is a column called `revision_translated_affected` which is used to indicate the affecting language of the revision.

Here is the revision_translated_affected explanation. https://git.drupalcode.org/project/drupal/blob/HEAD/core/lib/Drupal/Core...

However, there is a function in ContentEntityStorageBase class called populateAffectedRevisionTranslations, which is the function to populate the affected flag for all the revision and make sure all the revision in each language is correct and separate.

Here is the problem.

Because we save the data to the database with encrypt value called it "[ENCRYPTED]", and the data in the form interface haven't been encrypt yet.

Which means when we save/update a language translation, the others will always show translation affected too because of the data "[ENCRYPTED]" and the unencrypted data is not the same.

/**
   * Ensures integer entity key values are valid.
   *
   * The identifier sanitization provided by this method has been introduced
   * as Drupal used to rely on the database to facilitate this, which worked
   * correctly with MySQL but led to errors with other DBMS such as PostgreSQL.
   *
   * @param array $ids
   *   The entity key values to verify.
   * @param string $entity_key
   *   (optional) The entity key to sanitise values for. Defaults to 'id'.
   *
   * @return array
   *   The sanitized list of entity key values.
   */
  protected function cleanIds(array $ids, $entity_key = 'id') {
    $definitions = $this->entityFieldManager->getActiveFieldStorageDefinitions($this->entityTypeId);
    $field_name = $this->entityType->getKey($entity_key);
    if ($field_name && $definitions[$field_name]->getType() == 'integer') {
      $ids = array_filter($ids, function ($id) {
        return is_numeric($id) && $id == (int) $id;
      });
      $ids = array_map('intval', $ids);
    }
    return $ids;
  }

Although the function is still working, but the node's revisions will show a lot of duplicates in each languages.
Instead, it should show only the revision log on the language we modified.

Please take a look.

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

cobenash created an issue. See original summary.

ptmkenny’s picture

Title: The encrypt field caused the revision duplicate error » Encrypted field can cause a revision duplicate error
Project: Encrypt » Field Encryption
Version: 8.x-3.x-dev » 4.0.x-dev

This bug report was filed against the Encrypt module, but it is actually an issue with the Field Encryption module. I'm moving it to the correct issue queue and will attempt to investigate it later.

ptmkenny’s picture

Version: 4.0.x-dev » 4.x-dev