Improve hook_entity_presave documentation

Created on 7 January 2021, almost 5 years ago
Updated 22 February 2023, over 2 years ago

API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

Currently says:

You can get the original entity object from $entity->original when it is an update of the entity.

This is ambiguous in a multi-language context and could be improved.

In the following scenario, I was expecting $node->original to be the original version of the entity before it was updated, but it is not. It's actually the default translation of the entity (eg. the same as you'd get from doing a Node::load($nid).

* Add a new node in the [site] default language
* Add and save a translation of it
* Edit and save the translation

In hook_entity_presave(), $node->original is actually not the original translation that was edited, but is seemingly just the result of Node::load() on the ID of the edited node.

(If this is not the expected behaviour, I will change this to be a code bug rather than a documentation improvement!)

๐Ÿ› Bug report
Status

Active

Version

9.5

Component
Documentationย  โ†’

Last updated about 1 month ago

No maintainer
Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom nicrodgers Monmouthshire, UK

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • Documentation

    Primarily changes documentation, not code. For Drupal core issues, select the Documentation component instead of using this tag. In general, component selection is preferred over tag selection.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024