Auto Apply does not support content moderation

Created on 5 September 2025, about 2 months ago

Problem/Motivation

ISSUE 1 - Content Moderation:
When using the auto_apply_suggestions configuration, the batch AiReferenceBatch::batchFinished() loads the default revision in the default language with <code>Node::load(). This is incorrect when using content moderation and translations. With content moderation, the default revision may not be the latest revision when there is a published revision and a forward draft revision. In this case, the latest translation affected revision is used on the node edit forms.

ISSUE 2 - Translations:
This loading issue also exposes the fact that the "Generate references with AI" is attached to any node form, even translations. However, the taxonomy fields may not be translatable.

Steps to reproduce

  • Install content moderation, content translations, and AI Auto-reference.
  • AI Auto-reference configuration - enabled Auto Apply Suggestions
  • Generate references with AI

Proposed resolution

ISSUE 1 - Content Moderation:
Update:

$node = Node::load($results['nid']

To:

$node = \Drupal::service('entity.repository')->getActive('node', $results['nid']);

This will get the latest translated affected revision in the current content language.

ISSUE 2 - Translations:
Since this processes on node translation forms too, the value and form processing may need to be updated to handle which fields can be modified for the current translation.

Remaining tasks

Finalize solution.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States recrit

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024