drupal_entity does not support content moderation

Created on 7 September 2023, about 1 year ago
Updated 18 June 2024, 5 months ago

Problem/Motivation

Currently, drupal_entity_ doesn't use the revision data/latest revision of an entity.
When using content_moderation, this node contains the latest published version data, instead of the data from a newer "draft" version

Steps to reproduce

  1. Enable content moderation on a node.
  2. Create a node and publish it.
  3. Make some changes to the node and set the moderation state to draft.
  4. Render the entity using drupal_entity('node', 1) from the twig template
  5. The node doesn't contain the latest changes.
  6. Similarly if you go to revision history and from the revision list open the revision (say for the moderation state set to draft or any other) the updated data is not being rendered.

Proposed resolution

Load the revision data accordingly instead of rendering the latest published version.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: works as designed

Version

3.2

Component

Code

Created by

🇮🇳India Deepthi kumari

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

Comments & Activities

  • Issue created by @Deepthi kumari
  • 🇷🇺Russia Chi

    Load the revision data accordingly instead of rendering the latest published version.

    That's expected behavior. Isn't it? Why would we display unpublished nodes?

  • Status changed to Closed: works as designed 10 months ago
  • 🇺🇸United States dzinkevich

    Coming here with the same issue. One use case is that I inherited a client who has a hero image which is configured at the node level but displayed outside of the node's content region.

    When a user submits this node for approval, we don't want to display the current revision, we want to show the revision of the page that we get from the route.

    Going to look into this and see how difficult a patch would be.

  • 🇺🇸United States dzinkevich

    Looks like a patch was very very easy :)

    I'm not sure if this is the direction maintainers would like to go, but this adds a twig function that finds the field of a given revision.

  • 🇷🇺Russia Chi

    I wonder if {{ node.field_image|view }} works for your case.

Production build 0.71.5 2024