Add an option to prevent the changed date from being updated.

Created on 7 June 2023, about 1 year ago

Problem/Motivation

When updating various nodes, all of them will have their updated date changed to the current date which may confuse administrators to see that all content where just updated and sometimes could end up being visible on front if this field is displayed.

Steps to reproduce

Batch update several content and see the "Updated" column in /admin/content.

Proposed resolution

Add an option in the "Select fields to change" form to left the date untouched.

As a reference we have :

Remaining tasks

Patch to be written.

I don't have time right now to work on this feature, but here is a small code to help dealing with this problem.

/**
 * Implements hook_entity_presave().
 * Prevent changed date from bein update when running batches / using VBO.
 */
function MODULE_entity_presave(EntityInterface $entity) {
  if (\Drupal::routeMatch()->getRouteName() == 'system.batch_page.json' && isset($entity->original->changed)) {
    $entity->changed = $entity->original->changed;
  }
}
✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France tostinni

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

Comments & Activities

Production build 0.69.0 2024