Changing field value in an entity presave hook will not update the entity changed timestamp

Created on 28 September 2017, about 7 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

This is a follow-up from #2837022: Concurrently editing two translations of a node may result in data loss for non-translatable fields β†’ and detected thanks to the manual testing done by @matsbla so please make sure that he receives credit on this issue.

The problem found in #41 β†’ @matsbla is that content_translation allows for making only specific field properties translatable or not translatable and syncs the non-translatable properties in hook_entity_presave(), which means content_translation will be updating a field after the check for changes by ChangedItem::preSave() has run. This makes it impossible to update the changed timestamp, because the entity field preSave method is invoked before the entity presave hooks.

Proposed resolution

Invoke ChangedFieldItemList::preSave() once again after all the presave process has run to detect all changes that have been made during the presave process.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
EntityΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡©πŸ‡ͺGermany hchonov πŸ‡ͺπŸ‡ΊπŸ‡©πŸ‡ͺπŸ‡§πŸ‡¬

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.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.71.5 2024