Prevent the changed date of entities to be updating when removing a reference

Created on 5 March 2025, 5 months ago

Problem/Motivation

Now, when for example a node is saved to remove an orphaned entity reference, its changed date is updated. That shouldn't happen since this isn't an actual update, it's just behind the scenes maintenance.

Proposed resolution

Mark the entity as syncing before saving. See this change record → for more information.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium dieterholvoet Brussels

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

Merge Requests

Comments & Activities

  • Issue created by @dieterholvoet
  • 🇧🇪Belgium dieterholvoet Brussels
  • Pipeline finished with Success
    5 months ago
    Total: 165s
    #441028
  • 🇧🇪Belgium dieterholvoet Brussels
  • First commit to issue fork.
  • Pipeline finished with Success
    4 months ago
    #463444
  • 🇫🇷France mably

    Really nice feature to have, thanks!

    Pushed a commit to add a missing import.

  • Status changed to Needs review 10 days ago
  • 🇷🇸Serbia gnikolovski Subotica, Serbia

    Can you add a test for this? It seems pretty straightforward.

  • 🇫🇷France mably

    Actually I cannot reproduce the problem on Drupal 11.2.

    Calling $entity->save() doesn't seem to update the changed timestamp.

    @dieterholvoet could you provide a detailed scenario to reproduce the problem on a fresh Drupal 11 instance?

  • 🇫🇷France mably
  • 🇫🇷France mably

    EDIT: Ok, it looks like it's because I'm creating and updating the node in the same request, so the \Drupal::time()->getRequestTime() value is the same when updating the node...

  • 🇫🇷France mably

    Tried to implement some basic changed timestamp preservation tests.

    Added a basic test time service to allow changing the request time during test.

    I'm not a test expert, so any feedback will be greatly appreciated.

  • Pipeline finished with Failed
    9 days ago
    Total: 166s
    #551842
  • Pipeline finished with Failed
    9 days ago
    Total: 153s
    #551845
  • Pipeline finished with Failed
    9 days ago
    Total: 152s
    #551848
  • Pipeline finished with Failed
    9 days ago
    Total: 154s
    #551850
  • Pipeline finished with Success
    9 days ago
    Total: 230s
    #551869
  • Pipeline finished with Success
    9 days ago
    Total: 238s
    #551917
Production build 0.71.5 2024