Summary
Since Drupal 11.1, the changed timestamp is no longer updated when using the "Publish Latest Revision" bulk action. The content is published correctly, but the changed date retains its previous value.
Root cause
In Drupal 11.1.0, the behavior of setSyncing(TRUE) was changed to explicitly preserve the original changed timestamp on save (see Change Record #3250104).
In AdminModeration::publish() (line 167), the code calls:
$this->entity->setSyncing(TRUE);
Prior to Drupal 11.1, this did not prevent the changed field from being automatically updated. Now it does, which means bulk-published content keeps its old changed date.
Affected methods
AdminModeration::publish() — line 167
AdminModeration::unpublish() — line 92 (same issue applies)Note: AdminModeration::archive() already has setSyncing(TRUE) commented out (line 257), so it is not affected.
Suggested fix
Explicitly set the changed timestamp before saving:
$this->entity->setChangedTime(\Drupal::time()->getRequestTime());
This should be added before the $this->entity->save() call in both publish() and unpublish() methods. This preserves the setSyncing(TRUE) behaviour for other purposes while ensuring the changed date reflects when the action was performed.
Issue fork moderated_content_bulk_publish-3573928
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
andy_w commentedComment #5
joseph.olstadVery good, thank you for this important fix! I'll tag and release shortly.
Comment #6
joseph.olstadThis might also be needed for 3.0.x, I'll check now.
Comment #8
joseph.olstadComment #11
joseph.olstadThanks @andy_w!
Here's the release:
https://www.drupal.org/project/moderated_content_bulk_publish/releases/2...