Comparing content moderation state change

Created on 3 March 2023, about 2 years ago
Updated 29 March 2023, about 2 years ago

Problem/Motivation

Following 3292867 closed issue β†’ adding a step to the process: how about getting the former state?

Steps to reproduce

I've tried the following 'Load entity' action settings:

'unchanged' entity loaded with
- Load latest revision: 'no'
- Load unchanged values: 'no'
moderation_state field unchanged: new state
moderation_state field updated: new state
=> this is logic as the unchanged entity is the same as the changed one

'unchanged' entity loaded with
- Load latest revision: 'no'
- Load unchanged values: 'yes'
moderation_state field unchanged: 'published' whichever transition where used
moderation_state field updated: new state
=> this seems logic as we've loaded the currently published revision

'unchanged' entity loaded with
- Load latest revision: 'yes'
- Load unchanged values: 'no'
moderation_state field unchanged: new state
moderation_state field updated: new state
=> This is logic as the unchanged entity is the same as the changed one

'unchanged' entity loaded with
- Load latest revision: 'yes'
- Load unchanged values: 'yes'
moderation_state field unchanged: new state
moderation_state field updated: new state
=> this seems logic if the 'Load latest revision' takes priority over 'Load unchanged values'

Is there a way to get the moderation_state value before it has been changed?
I suspect I'll need to load the penultimate revision...

πŸ’¬ Support request
Status

Fixed

Version

1.1

Component

Documentation

Created by

πŸ‡«πŸ‡·France PhilY πŸ‡ͺπŸ‡ΊπŸ‡«πŸ‡· Paris, France

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @PhilY
  • Status changed to Postponed: needs info about 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @PhilY have you had a chance to give the proposed a solution a try?

  • πŸ‡«πŸ‡·France PhilY πŸ‡ͺπŸ‡ΊπŸ‡«πŸ‡· Paris, France

    @jurgenhaas:
    The process I'm trying to set up should react on both "Insert content entity" and "Update content entity" events.
    Basically, it's an email notification which recipent depends on the updated state.

    For "update", the core patch you provided at https://www.drupal.org/project/drupal/issues/3346430 πŸ› Wrong revision can be loaded into original in \Drupal\Core\Entity\EntityStorageBase::doPreSave Needs work works using Drupal 9.5.5, ECA 1.1.2 & PHP 8.1.6

    For "insert", both before and after moderation states have the same value (the new one) but that may be designed by core as there is no previous state.
    Anyway, I just need to add a test in the loop for new entities.

    So, I can now check previous moderation state against new one on node update event, thanks a lot.

  • Status changed to Fixed about 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Marking this as fixed. Regarding the insert entity event, I think it is expected, that a new entity is not actually changing state, it gets its initial state.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024