Skip to content

Events After saving / updating nodes of type happen before record is written to database #175

@yorkshire-pudding

Description

@yorkshire-pudding

The UI for rules events is misleading.

image

There are several possible events that say "after" but the actions happen before. I confirmed this using Rules Throttle which I ported so I could check in a view whether the change had happened.

It is very misleading as there is also an event that says "before saving content". If all the "after" events actually take place before the save, what does the "before" event do?

I've come across this on nodes, but I think this could apply across the board on other entities. I couldn't find anything on our issue queue but checked on Drupal and found this:
https://www.drupal.org/project/rules/issues/2877239

I then looked up our docs which both say:

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check node_save() and db_transaction() for more info.

https://docs.backdropcms.org/api/backdrop/core%21modules%21node%21node.api.php/function/hook_node_insert/1
https://docs.backdropcms.org/api/backdrop/core%21modules%21node%21node.api.php/function/hook_node_update/1

I have two questions:

  1. Is there any way in rules to do actions after the save event?
  2. Should we be looking to improve the UX here so that user expectations are managed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions