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
- Install the module on a multilingual site with at least two languages.
- Create a node with translations in both languages and save it.
- Query the
content_first_audittable:SELECT entity_id, language FROM content_first_audit WHERE entity_id = nid - 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.
Issue fork content_first-3587558
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 #2
eduardo morales albertiComment #5
eduardo morales albertiMerged