Problem/Motivation

In hook_node_insert and hook_node_update, _content_first_audit_process_node() renders and audits the $node object as passed by the hook, which is in a single language (the one being saved or the site default).

Translations in other languages are never rendered or stored, so the content_first_audit table only ever contains one row per node, for the default language, even when the node has multiple translations.

Steps to reproduce

  1. Install the module on a multilingual site with at least two languages.
  2. Create a node with translations in both languages and save it.
  3. Query the content_first_audit table: SELECT entity_id, language FROM content_first_audit WHERE entity_id = nid
  4. Observe that only one row exists (for the default language), with no row for the other translation(s).

Proposed resolution

Update _content_first_audit_process_node() to iterate over all translations returned by
$node->getTranslationLanguages(), load each translation with $node->getTranslation($langcode), and call upsert() for each one.

After processing, call a new repository method deleteByEntityExcludingLanguages() to remove any audit rows for languages that are no longer present on the node (handles the case where a translation is deleted, which fires hook_node_update with the remaining translations).

New interface method and implementation added to AuditRepositoryInterface and AuditRepository.

Remaining tasks

  • Review and test on a multilingual site.
  • Add automated test coverage for multi-translation upsert and stale-row cleanup.

User interface changes

The audit report now shows one row per node per language translation instead of only one row per node.

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

eduardo morales alberti’s picture

Status: Active » Fixed

Merged

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.